Reputation: 2851
Below is some javascript based on the Google Maps documentation. It should display a marker at the LatLng coordinates indicated. However, it is showing the map only without the marker. Can someone point out what I've done wrong? I've been staring at this for a long time and can't figure it out. Also, I need to modify this code to accept two arrays of marker coordinates. Each array is to get a different marker icon: red.png, yellow.png and blue.png. I plan to eventually get the coordinates for each marker group by calling a server-side webmethod (C#). But for simplicity let's ignore that requirement for the moment and assume we have three static arrays. Can someone show me what I need to do? I've seen a lot of similar questions on S.O. but none of the answers seem to work for me.
<script type="text/javascript" src="http://maps.google.com/maps?file=api&sensor=true">
<script type="text/javascript">
var map;
function initialize() {
var myOptions = {
zoom: 5,
center: new google.maps.LatLng(39.50, -98.35),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'),
myOptions);
map.addOverlay(new google.maps.Marker(
new google.maps.LatLng(39.50, -98.35)));
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
Upvotes: 0
Views: 182
Reputation: 9292
Markers are created as:
var marker = new google.maps.Marker({
position: new google.maps.LatLng(39.50, -98.35),
map: map
//, ...
});
Upvotes: 1