Reputation: 11041
I am using goMap jQuery plugin for integrating Google Maps api v3. I am having problem when I want to redraw map. I have 2 input boxes for entering Latitude and Longitude and then a text link on which I trigger goMap javascript code... When this is called first time map renders fine, but then if I change Latitude/Longitude values and call the same code again the map isnt redrawn to the new coordinates... My code looks like
<input id="form_office_latitude" class="span4 office_latitude" type="text" name="office_latitude" value="">
<input id="form_office_longitude" class="span4 office_longitude" type="text" name="office_longitude" value="">
<a class="check-map" href="javascript:{};">Preveri zemljevid</a>
$('.check-map').live('click', function(){
$("#map_canvas").goMap({
maptype: 'ROADMAP',
zoom: 15,
markers: [{
icon: base_url+'assets/img/marker.png',
latitude: $('.office_latitude').val(),
longitude: $('.office_longitude').val(),
id: 'test',
html: {
content: 'Hello Word!',
popup: true
}
}],
hideByClick: false
});
});
Upvotes: 2
Views: 1969
Reputation: 2554
I'm not an expert in the goMap plugin, but you probably don't want to redraw or recreate the map like you currently are (building an entire new map). Instead you want to recenter the map using something like:
var center = new google.maps.LatLng($('.office_latitude').val(),
$('.office_longitude').val());
$.goMap.map.setCenter(center);
Upvotes: 4