i’m using google maps v3 and i want create a new map associate to a event with a combo but i don’t know why don’t work, take a look to my code.
Note i debug the code and works great the problem it’s that the map doesn’t show
$(document).ready(initialize);
var map;
function initialize() {
x = $(".comboMap");
x.change(buildMap);
}
function buildMap(){
$.ajax({
async: false,
type: "POST",
url: "SaveIndicators.aspx/findMapParameters",
data: "{idMapa: '" + $(".comboMap").val() + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: response
});
}
/***Sets the values in the map****/
function response(values) {
var location = values.d.split(",");
var lat = parseFloat(location[0]);
var lng = parseFloat(location[1]);
var latLng = new google.maps.LatLng(lat, lng);
var mapDiv = $("#map-canvas")[0];
map = new google.maps.Map(mapDiv, {
center: latLng,
zoom: location[2],
mapTypeId: google.maps.MapTypeId.ROADMAP,
disableDefaultUI: true
});
}
You need to convert your string value for the zoom level to an integer:
I would have thought it would have cast the value passing the string, but it didn’t. I had to use parseInt() to make an integer to get the Map constructor to treat it correctly.