I have map on my si开发者_开发百科te but I don't kno how to add marker at this location (42.9967, 21.941667). Any help?
<script type="text/javascript">
function init() {
var mapDiv = document.getElementById('map');
var latlng = new google.maps.LatLng(42.9967, 21.941667);
var options = {
center: latlng,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(mapDiv, options);
};
$(document).ready(init);
</script>
Check this out:
var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
var myOptions = {
zoom: 4,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var marker = new google.maps.Marker({
position: myLatlng,
title:"Hello World!"
});
// To add the marker to the map, call setMap();
marker.setMap(map);
You've created the map and set the center, but you haven't actually created a marker.
var marker = new google.maps.Marker({
position: latlng,
map: map,
title:"Hello World!"
精彩评论