我已经在这方面工作了几天,但似乎仍然无法得到它。 我需要在地图上显示两个引脚。任何建议都会很棒。 以下是我到目前为止的情况:
$.martanianGoogleMapInit = function() {
var lat = 36.777259;
var lng = -76.036311;var map_center = new google.maps.LatLng( lat, lng );
var mapOptions = {
zoom: 1,
center: map_center,
mapTypeId: google.maps.MapTypeId.ROADMAP,
scrollwheel: false
}
var map = new google.maps.Map( document.getElementById( 'google-map' ), mapOptions );
var beachMarker = new google.maps.Marker({
position: new google.maps.LatLng( lat, lng ),
map: map
});
};
答案 0 :(得分:0)
Below seems to work for me using my own API key. I get two markers. You could choose to create a function that takes an input of array with multiple lat+lng values and iterate the "new google.maps.Marker()" function.
Ofcourse, as others have pointed out in the comments, you must have a reference to the Google Maps API in your , provided with your own API KEY.
$.martanianGoogleMapInit = function() {
var lat = 36.777259;
var lng = -76.036311;
var map_center = new google.maps.LatLng( lat, lng );
var mapOptions = {
zoom: 10,
center: map_center,
mapTypeId: google.maps.MapTypeId.ROADMAP,
scrollwheel: false
}
var map = new google.maps.Map( document.getElementById( 'google-map' ), mapOptions );
new google.maps.Marker({
position: new google.maps.LatLng( lat, lng ),
map: map
});
new google.maps.Marker({
position: new google.maps.LatLng( lat+0.0101, lng ),
map: map
});
};