Wednesday, June 8, 2011

[Google Maps API v2] Google Map Pop Up

I have a problem with jquery for google map to be displayed in my pop
up page when i click the link of details of hotels.

The main problem , when i clcik one hotel details a pop up appears and
shows details of hotel perfectly and google map is alos seen at first
time. But second time when i click the detail link of hotel only
details of hotel comes and no google map.

My code is as follows for displaying google map.

<script type="text/javascript" language="javascript">

$(document).ready(function () {

if (GBrowserIsCompatible()) {
var Id = $("#item_HotelId").val();

$.getJSON("/HotelGoogleMap/HotelsForMap", { id: Id },
function (data) {
refresh = true;
initialize(data);
});

}

function initialize(mapData) {
refresh = true;
var map = new
GMap2(document.getElementById("map_canvas"));

// map.addControl(new
google.maps.smallMapControl());
map.addControl(new google.maps.MapTypeControl());
map.setCenter(new GLatLng(mapData.Data[0].Latitude,
mapData.Data[0].Longitude), 16);

var zoom = mapData.zoom;

$.each(mapData, function (i, Hotel) {
setupLocationMarker(map, mapData);
});
}
function setupLocationMarker(map, Hotel) {

var latlng = new GLatLng(Hotel.Data[0].Latitude,
Hotel.Data[0].Longitude);
var marker = new GMarker(latlng);
map.addOverlay(marker);
}
});


</script>


And for popup page i have my own code like this:

function loadDetailsDialog(tag, event, target) {

// $dialog.dialog('close');
event.preventDefault();
var $loading = $('<img src="../../Content/images/
loadingAnimation.gif" alt="loading" class="ui-loading-icon">');
var $url = $(tag).attr('href');
var $title = $(tag).attr('title');
var $dialog = $('<div></div>');
$dialog.empty();
$dialog
.append($loading)
.load($url)
.dialog({
autoOpen: false
, title: $title
, width: 500
, modal: true
, minHeight: 500
, show: 'slide'
, hide: 'slide'

});

//
blind,bounce,clip,drop,explode,fold,highlight,puff,pulsate,scale,shake,size,transfer

$dialog.dialog('open');


};


and i have called in my details like this:

$('a.Details').live("click", function (event) {


loadDetailsDialog(this, event, '#contentGrid');

});


Every things ok for the first click to view google map but for second
time google map doesnot appears....why is it so? Please help me .Also
detect my code errors if any.

Thank you


--
You received this message because you are subscribed to the Google Groups "Google Maps API V2" group.
To post to this group, send email to google-maps-api@googlegroups.com.
To unsubscribe from this group, send email to google-maps-api+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-api?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate