;)
我对 Google Maps API 还不是很熟悉,但我能够找出初学者犯的大多数问题。;) 但我没有得到的是在我设置的两个标记之间将地图居中并自动缩放它...... ;(
也许有人对我有正确的提示......
谢谢和欢呼!
<script> function initialize() {
var myLatLng = new google.maps.LatLng(0, 0);
var mapOptions = {
zoom: 3,
mapTypeControl: false,
navigationControl: false,
scrollwheel: false,
streetViewControl: false,
zoomControl: false,
center: myLatLng,
mapTypeId: google.maps.MapTypeId.TERRAIN
};
var map = new google.maps.Map(document.getElementById('map'), mapOptions);
var flightPlanCoordinates = [
new google.maps.LatLng(100, 100),
new google.maps.LatLng(120, 120)
];
var lineSymbol = {
path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW
};
var flightPath = new google.maps.Polyline({
path: flightPlanCoordinates,
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 0.5,
icons: [{
icon: lineSymbol,
offset: '100%'
}],
strokeWeight: 2
});
flightPath.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);</script>
<div id="map" style="width: 100%; height: 300px"></div>
<script>jQuery('#myModal-<? the_ID(); ?>').on('shown', function () {
google.maps.event.trigger(map, 'resize');
map.setCenter(new google.maps.LatLng(42.3605336, -72.6362989));
})</script>