I am embedding the Google Maps API and I am showing the map in the jQuery dialog. The map shows a penalty, but the marker position is not in the center, so please guide me.
How can I make the marker and map position in the center?
Code for card:
var myCenter = new google.maps.LatLng('@Model.Latitude', '@Model.Longitude');
function initialize() {
var mapProp = {
center: myCenter,
zoom: 15, mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("googleMap"), mapProp);
var marker = new google.maps.Marker({
position: myCenter,
draggable: false,
animation: google.maps.Animation.DROP,
});
marker.setMap(map);
}
Code that opens the dialog box:
$("#googleMap").dialog({
autoOpen: false,
height: 600,
width: 1000,
resizeStop: function (event, ui) {
google.maps.event.trigger(googleMap, 'resize')
}, open: function (event, ui) {
google.maps.event.trigger(googleMap, 'resize'); },
});
$("#btnLocation").click(function () {
$("#googleMap").dialog("open");
});
HTML:
<div id="googleMap" style="width: 1000px; height: 500px"></div>
<img src="map.jpg" alt="Set Location" id="btnLocation" style="cursor: pointer; height: 35px; width: 35px;" />
source
share