Address instead of latLng

7,178 views
Skip to first unread message

kevin simmons

unread,
Nov 24, 2010, 3:14:00 PM11/24/10
to google-map...@googlegroups.com
I want to change it from latLng to address in the following code:

  var geocoder;
 
var map;
 
function initialize() {
    geocoder
= new google.maps.Geocoder();
   
var latlng = new google.maps.LatLng(-34.397, 150.644);
   
var myOptions = {
      zoom
: 8,
      center
: latlng,
      mapTypeId
: google.maps.MapTypeId.ROADMAP
   
}
But it does not work when I change "LatLng" to "address" and then change the(-34.397, 150.644) to (San Diego,CA).  Can someone please let me know what I am doing wrong?  I found another topic on this in this forum, but all of the links were dead, which caused me to post this question again.

Barry Hunter

unread,
Nov 24, 2010, 3:31:36 PM11/24/10
to google-map...@googlegroups.com
http://code.google.com/apis/maps/documentation/javascript/services.html#Geocoding

But you shouldnt be geocoding a known address on every page load.

> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps JavaScript API v3" group.
> To post to this group, send email to google-map...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-maps-js-a...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>

kevin simmons

unread,
Nov 24, 2010, 3:41:47 PM11/24/10
to google-map...@googlegroups.com
My expected results should be when you go to the page, it shows your location.  It will get this information from my db.  I will be adding a little php to handle this.
I am not too familiar with jsp, so the following code might look stupid but, I went to the link you sent me earlier in the day and tried the following (needless to say it failed miserably):


var map;
function initialize() {
  var myLatlng = new google.maps.address(San Diego, CA);
  var myOptions = {
    disableDefaultUI: true,
    zoom: 4,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.TERRAIN
  }
  map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
 
  google.maps.event.addListener(map, 'zoom_changed');
 
  var marker = new google.maps.Marker({
      position: myLatlng,
      map: map,
      title:<?php echo "full_name";?>
  });
  google.maps.event.addListener(marker, 'click');
}

What am I doing wrong that stops the map from display with a San Diego start point?
Thank you for the quick response.

geoco...@gmail.com

unread,
Nov 24, 2010, 6:17:16 PM11/24/10
to Google Maps JavaScript API v3
Example that geocodes "San Diego":
http://www.geocodezip.com/GMapsExampleV3b.html

-- Larry

kevin simmons

unread,
Nov 24, 2010, 6:38:07 PM11/24/10
to google-map...@googlegroups.com
Thank you so much for that, It worked perfectly.

Reply all
Reply to author
Forward
0 new messages