Jump to content

Mobile Google Maps GetLatLong From Physical Address - How ?


andyhill

Recommended Posts

Yes I have looked at that info but it has Lat / Long hard coded ?

 

How can I use

 

                       '  var carmarker = new google.maps.Marker '+
                       '  ( '+
                       '    { '+
//                     '      position: myLatLng, '+
                       '      address: ''1 Flinders Street, Melbourne, VIC 3000, Australia'', '+
                       '      map: gm, '+
                       '      icon: imagecar, '+
                       '      zindex: 0 '+
                       '    } '+
                       '  ); '+
 
 
With an address instead of position Lat / Long ?
 
Can you show me in code ? Thanks
Link to comment
Share on other sites

Or

https://store.falconsistemas.com.br

map_current_position.png

 

Simple Code:

procedure TfrmCurrentPosition.btnGetCurrentPositionClick(Sender: TObject);
begin
  map.GetCurrentPosition;
end;

procedure TfrmCurrentPosition.mapAjaxEvent(Sender: TComponent;
  EventName: string; Params: TUniStrings);
begin
  if EventName = 'fs_get_current_position' then
  begin
    if Params['status_geo'].Value = 'denied' then
      ShowMessage('Access coordinates permission denied');

    if Params['status_geo'].Value = 'enabled' then
    begin
      ShowMessage('Lat: '+Params['lat'].Value+' Lng: '+Params['lng'].Value+' Accuracy: '+ Params['accuracy'].Value+' mt');

      map.SetCenter(Params['lat'].Value, Params['lng'].Value);
    end;
  end;
end;

map_search.png

procedure TfrmSearchBox.btnSearchClick(Sender: TObject);
begin
  map.SearchBox(edtSearch.Text);
end;

procedure TfrmSearchBox.mapAjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName = 'fs_map_geocoder' then
  begin
    if Params.Values['notfound'] <> EmptyStr then
    begin
      ShowMessage(Params.Values['notfound']);
      Exit;
    end
    else
    begin
      map.SetCenter(Params.Values['lat'], Params.Values['lng']);
      map.SetZoom(13);
    end;
  end;
end;
Link to comment
Share on other sites

I have no problems getting current position Lat / Long.

 

I have no problems going to Lat / Long.

 

What I need help with is calculating the Lat / Long from a Formatted_Address within JavaScript below (how to use gm.SearchBox for Marker) ?

 

address: '1 Flinders Street, Melbourne, VIC 3000, Australia'

 

      UniSession.AddJS('var gm = googleMap; '+
                       'if (typeof gm == "object") '+
                       '{ '+
 
                       '  var imagecar = ''car.png''; '+
                       '  var carmarker = new google.maps.Marker '+
                       '  ( '+
                       '    { '+
                       '      address: ''1 Flinders Street, Melbourne, VIC 3000, Australia'', '+
                       '      map: gm, '+
                       '      icon: imagecar, '+
                       '      zindex: 0 '+
                       '    } '+
                       '  ); '+
Link to comment
Share on other sites

This is one of my many attempts but fails (any advice would be appreciated):-

 

UniSession.AddJS('var gm = googleMap; '+
                       'if (typeof gm == "object") '+
                       '{ '+
 
                       '  var imagecar = ''car.png''; '+
                       '  var searchBox = new google.maps.places.SearchBox(''1 Flinders Street, Melbourne, VIC 3000, Australia''); '+
                       '  var places = searchBox.getPlaces(); '+
                       '  if (places.length != 0) '+
                       '  { '+
                       '    places.forEach '+
                       '    ( '+
                       '      function(place) '+
                       '      { '+
                       '        markers.push '+
                       '        ( '+
                       '          new google.maps.Marker '+
                       '          ( '+
                       '            { '+
                       '              map: gm, '+
                       '              icon: imagecar, '+
                       '              title: place.name, '+
                       '              position: place.geometry.location '+
                       '            } '+
                       '          ) '+
                       '        ) '+
                       '      } '+
                       '    ); '+
                       '  } '+
 
                       '} '
                       );
Link to comment
Share on other sites

Farshad, I need to walk through a formatted address array and fetch the Latitude / Longitude from the Google Maps Service (I do not want to paint on map, just collect the Lat/Lng) can you please advise - thanks. 

Link to comment
Share on other sites

×
×
  • Create New...