jquery-ui-map を使用しており、ユーザーの場所にズーム レベルを設定する必要があります。現在、ユーザーを見つけてから完全にズームインしますが、さらにズームアウトしたいです。JavaScript のスキルが不足しており、答えを探していろいろ試してみましたが、何もうまくいかないようです。これがコードです...
jQuery('#map_canvas').gmap({'center': '-23.7002104, 133.8806114','zoom': 3 }).bind('init', function() {
jQuery('#map_canvas').gmap('getCurrentPosition', function(position, status) {
if ( status === 'OK' ) {
var clientPosition = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
jQuery.getJSON( 'http://publicaccessgolf.com.au/mapdata/', function(data) {
jQuery.each( data.course, function(i, course) {
jQuery('#map_canvas').gmap('addMarker', {
'position': new google.maps.LatLng(course.latitude, course.longitude),
}).click(function() {
jQuery('#map_canvas').gmap('openInfoWindow', { 'content': '<div align="left"><p style="color:#000000;"><a href="http://publicaccessgolf.com.au/' + course.slug + '" >' + course.name + '</a><br />' + course.address + '<br />' + course.contact + '</p></div>' }, this);
});
});
});
jQuery('#map_canvas').gmap('addMarker', {'position': clientPosition, 'zoom': 3});
}
});
});
さて、私はそれを解決しました、正しいコードは以下です。ズームの代わりに maxZoom を使用
jQuery('#map_canvas').gmap({'center': '-23.7002104, 133.8806114','maxZoom': 11}).bind('init', function() {
jQuery('#map_canvas').gmap('getCurrentPosition', function(position, status) {
if ( status === 'OK' ) {
var clientPosition = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
jQuery.getJSON( 'http://publicaccessgolf.com.au/mapdata/', function(data) {
jQuery.each( data.course, function(i, course) {
jQuery('#map_canvas').gmap('addMarker', {
'position': new google.maps.LatLng(course.latitude, course.longitude),
}).click(function() {
jQuery('#map_canvas').gmap('openInfoWindow', { 'content': '<div align="left"><p style="color:#000000;"><a href="http://publicaccessgolf.com.au/' + course.slug + '" >' + course.name + '</a><br />' + course.address + '<br />' + course.contact + '</p></div>' }, this);
});
});
});
jQuery('#map_canvas').gmap('addMarker', {'position': clientPosition, 'bounds':true});
}
});
});