If you could provide a link to the code running somewhere it would
help someone debug it.

On Jan 12, 4:45 pm, bennyhill <[email protected]> wrote:
> I can't seem to add a marker to a map from within a callback function.  I
> have this code.
>
>         var map;
> $.get(url, function(data) {
> var coordinates = JSON.parse(data);
> var latlng = new google.maps.LatLng(coordinates[0], coordinates[1]);
> var myOptions = {
>           center: latlng,
>           zoom: 10,
>           mapTypeId: google.maps.MapTypeId.ROADMAP
>         };
>
> map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
> var marker = new google.maps.Marker(
>            { position: new google.maps.LatLng(41.7056381, -72.5559746),
>              map: map
>            });
>
> });
>
> The map shows up in the page fine but no marker.  If I move all this code
> from outside the callback it works with the marker.  Any thoughts?  Been at
> this for two hours now.

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to