Jump to content


Photo

Mobile Google Maps GetLatLong From Physical Address - How ?

address

  • Please log in to reply
7 replies to this topic

#1 andyhill

andyhill

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 346 posts
  • LocationMelbourne Australia

Posted 30 January 2018 - 04:50 AM

I have Google Maps working and locating current position - all fine.

 

Can someone please show me how to geolocate an Address and return the Lat Long - thanks.

 


  • 0

Andy


#2 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 4969 posts

Posted 30 January 2018 - 10:36 AM

Hi,

 

https://developers.g...geocoding/start


  • 0

#3 andyhill

andyhill

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 346 posts
  • LocationMelbourne Australia

Posted 30 January 2018 - 10:57 AM

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

  • 0

Andy


#4 Marlon

Marlon

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 368 posts
  • LocationNova Mutum - MT - Brasil

Posted 30 January 2018 - 12:49 PM

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;

  • 0

#5 andyhill

andyhill

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 346 posts
  • LocationMelbourne Australia

Posted 30 January 2018 - 06:30 PM

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 '+
                       '    } '+
                       '  ); '+

  • 0

Andy


#6 andyhill

andyhill

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 346 posts
  • LocationMelbourne Australia

Posted 30 January 2018 - 08:41 PM

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 '+
                       '            } '+
                       '          ) '+
                       '        ) '+
                       '      } '+
                       '    ); '+
                       '  } '+
 
                       '} '
                       );

  • 0

Andy


#7 andyhill

andyhill

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 346 posts
  • LocationMelbourne Australia

Posted 03 February 2018 - 10:37 PM

I really need help here, can some one please advise - thanks


  • 0

Andy


#8 andyhill

andyhill

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 346 posts
  • LocationMelbourne Australia

Posted 06 February 2018 - 08:24 AM

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. 


  • 0

Andy






Also tagged with one or more of these keywords: address

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users