andyhill Posted January 30, 2018 Share Posted January 30, 2018 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. Link to comment Share on other sites More sharing options...
Sherzod Posted January 30, 2018 Share Posted January 30, 2018 Hi, https://developers.google.com/maps/documentation/geocoding/start Link to comment Share on other sites More sharing options...
andyhill Posted January 30, 2018 Author Share Posted January 30, 2018 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 More sharing options...
Marlon Nardi Posted January 30, 2018 Share Posted January 30, 2018 Orhttps://store.falconsistemas.com.br 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; 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 More sharing options...
andyhill Posted January 30, 2018 Author Share Posted January 30, 2018 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 More sharing options...
andyhill Posted January 30, 2018 Author Share Posted January 30, 2018 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 More sharing options...
andyhill Posted February 3, 2018 Author Share Posted February 3, 2018 I really need help here, can some one please advise - thanks Link to comment Share on other sites More sharing options...
andyhill Posted February 6, 2018 Author Share Posted February 6, 2018 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 More sharing options...
Recommended Posts