1 Reply Latest reply on Dec 21, 2011 5:03 PM by szerobert

    Retrieving Latitude/Longitude data from Google Maps

    GaryRogers87

      I'm very sorry if this isn't the correct place to ask such questions, but i'm getting very stuck here. I've been googling for hours and I cannot figure this out.

       

      I have found help on using Lat/Lng data to conduct a search and even to display multiple markers on the map from XML data using Lat/Lng co-ordinates, but all of these assume that I know the co-ordinates that I want to use. My eventual aim is to allow users to specify their location and the data will be recorded in XML. I can perform a successful search, but it seems like a bad idea to store the search keywords that the user typed to find their current location. I need users to store their exact Lat/Lng.

       

      Currently users perform a search and a marker is displayed wherever the search lands, but i'd like to retrieve that Lat/Lng of the marker location and display them somewhere. Can anybody help with this? Here is my current script block.

       

      --------------------------------------------------------

       


      <fx:Script>



      <![CDATA[




      import com.google.maps.InfoWindowOptions;




      import com.google.maps.LatLng;




      import com.google.maps.Map;




      import com.google.maps.MapEvent;




      import com.google.maps.MapMouseEvent;




      import com.google.maps.MapType;




      import com.google.maps.MapUtil;




      import com.google.maps.controls.MapTypeControl;




      import com.google.maps.controls.PositionControl;




      import com.google.maps.controls.ZoomControl;




      import com.google.maps.overlays.Marker;




      import com.google.maps.overlays.MarkerOptions;




      import com.google.maps.services.ClientGeocoder;




      import com.google.maps.services.GeocodingEvent;




      import com.google.maps.services.GeocodingResponse;




      import com.google.maps.services.Placemark;




      import com.google.maps.styles.FillStyle;




      import mx.controls.Alert;




      import mx.events.FlexEvent;























      public static var DEFAULT_MAP_CENTER:LatLng = new LatLng(51.506321, -0.12714);



















      protected function mapreadyHandler(event:MapEvent):void




      {









      googleMap.addControl(new ZoomControl());





      googleMap.addControl(new MapTypeControl());





      googleMap.setCenter(DEFAULT_MAP_CENTER, 12, MapType.NORMAL_MAP_TYPE);





      googleMap.enableScrollWheelZoom();











      }










      private function doGeocode(event:Event):void {





      var geocoder:ClientGeocoder = new ClientGeocoder();





      geocoder.addEventListener(






      GeocodingEvent.GEOCODING_SUCCESS,






      function(event:GeocodingEvent):void {







      var placemarks:Array = event.response.placemarks;







      if (placemarks.length > 0) {








      googleMap.setCenter(placemarks[0].point);







      var marker:Marker = new Marker(placemarks[0].point);
















      marker.addEventListener(MapMouseEvent.CLICK, function (event:MapMouseEvent):void {








      marker.openInfoWindow(new InfoWindowOptions({content: placemarks[0].address}));







      });







      googleMap.addOverlay(marker);















      }






      });





      geocoder.addEventListener(






      GeocodingEvent.GEOCODING_FAILURE,






      function(event:GeocodingEvent):void {







      Alert.show("This location could not be found. Try again.");







      trace(event);







      trace(event.status);






      });





      geocoder.geocode(address.text);





      confirmCity.visible=true;





      submitCity.visible=true;




      }










      ]]>


      </fx:Script>

        • 1. Re: Retrieving Latitude/Longitude data from Google Maps
          szerobert

          Hi !

           

          I think i can help you with this. You have 3 options i think. i have done it all because we work on web directories for local businesses.

          1 - when your users submit data you your google map performs a geocoding process .My users can enter address which is geocoded immediately then they are allowed to drag the marker to the exact position.

               the map api returns the latitude longitude coordinates into to two seperate input text values. When the form gets submitted latitude and longitude coordinates are inserted into  the database with the rest of the data.

           

          2  you make a map which displays the coordinates

           

          3  you grab one of my widgets which shows you the coordinates which can be adjusted after inputting address

          http://www.latitude-longitude-finder.com/geocoder-widget.php