Hey!
I'm using Google Maps API v2 (for some reason, it has to be the v2) and jQuery UI 1.8.6 (and jQu开发者_StackOverflow社区ery 1.4.1).
The situation is: I have a map inside a modal dialog.
The Problem is: When i click on the shadow of the info "balloon" and drag the map, it won't stop dragging.
I really don't know which code should i provide, so, if you want me to put some code specifically just let me know.
function createMarker(latitude, longitude, num, color, id_local) {
var iconOptions = {};
iconOptions.width = 32;
iconOptions.height = 32;
iconOptions.primaryColor = ''+color;
iconOptions.label = ''+num;
iconOptions.cornerColor = "#82c4e8";
iconOptions.strokeColor = "#000000";
var newIcon = MapIconMaker.createLabeledMarkerIcon(iconOptions);
//
var point = new GLatLng(latitude,longitude,0);
//
var marker = new GMarker(point, {
icon: newIcon
});
var html = $('#info_mapa_'+id_local).html();
GEvent.addListener(marker, 'click', function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
Thank you.
My boss decided to spent a day migrating to v3 and get rid of this stupid problem. Thanks everybody.
UPDATE
DEMO: http://jsbin.com/ofuze4
DEMO: https://so.lucafilosofi.com/google-maps-api-v2-jquery-ui-dialog-non-stoppable-dragging-problem/
PSEUDO CODE:
JS:
$(function() {
$("#j-dialog").dialog({
resizable: false,
width: 500,
height: 400,
open: function() {
initialize();
}
});
});
function initialize() {
var latlng = new google.maps.LatLng( - 34.397, 150.644);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map($("#map_canvas")[0], myOptions);
var contentString = $('#map-info').text();
var infowindow = new google.maps.InfoWindow({
content: contentString
});
var newIcon = 'http://cdn2.iconfinder.com/data/icons/oxygen/48x48/actions/note2.png';
var marker = new google.maps.Marker({
icon: newIcon,
position: latlng,
map: map,
title: "Hello World!"
});
google.maps.event.addListener(marker, 'click',
function() {
infowindow.open(map, marker);
});
}
CSS:
<style>#map_canvas { margin:0 auto; width:450px; height: 340px }</style>
HTML:
<div title="google maps inside jquery dialog" id="j-dialog">
<div id="map_canvas">
</div>
</div>
hope this help
REFERENCE:
- http://code.google.com/intl/it-IT/apis/maps/documentation/javascript/examples/index.html
精彩评论