Google Maps Api Java Script
I am trying to display a simple marker on my map. I follow all the steps as shown in the example but no markers attaches. this is the block with script: which is the bug? why d
Solution 1:
Simple example of creating markers on a map :
// this is list of markers with title / long and latvar locations = [
['Bondi Beach', -33.890542, 151.274856, 4],
['Coogee Beach', -33.923036, 151.259052, 5],
['Cronulla Beach', -34.028249, 151.157507, 3],
['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
['Maroubra Beach', -33.950198, 151.259302, 1]
];
// This creates the map with zoom level / default center and map typevarmap = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: new google.maps.LatLng(-33.92, 151.25),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
// this loops the array of marker locationsfor (i = 0; i < locations.length; i++) {
// this creates the markers and adds them to the map
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map
});
}
Working example : http://jsfiddle.net/QvNUF/95/
Update
To add a single marker do this :
var marker = new google.maps.Marker({
position: new google.maps.LatLng(<yourlat>, <yourlong>),
map: <yourmap>
});
you will need to replace <yourlat>
with the latitude of the marker position, <yourlong>
with the longitude of your marker position and <yourmap>
with the map variable you created
Post a Comment for "Google Maps Api Java Script"