Reputation: 47947
This is my code :
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript">
function load() {
if (GBrowserIsCompatible()) {
var map;
var location = new google.maps.LatLng(46.084989, 11.118851);
var stylez =
[
{
featureType: "all",
elementType: "all",
stylers: [
{ saturation: -98 }
]
}
];
var mapOptions = {
zoom: 11,
center: location,
mapTypeControlOptions: {
mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'myScale']
}
};
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
var mapType = new google.maps.StyledMapType(stylez, { name: "Grayscale" });
map.mapTypes.set('myScale', mapType);
map.setMapTypeId('myScale')
}
}
$(document).ready(function(){
load();
});
</script>
<div id="map_canvas" style="width: 100%; height: 700px"></div>
but nothing is loaded. Where am I wrong? Removing GBrowserIsCompatible() it works, but it doesn't recognize the location.
Upvotes: 0
Views: 413
Reputation: 249
Map API V2 is deprecated use V3. If you remove GBrowserIsCompatible() it will work and the map will be centered at your desired coordinates.
To highlight better the location you could use a marker
var marker = new google.maps.Marker({
position: location,
map: map,
title:"My location title"
});
Upvotes: 2
Reputation: 1118
I think you are trying to use Gmaps API V3 and GBrowserIsCompatible() is not supported with that version. In order to use this functionality you need to use API V2.
<script src="http://maps.google.com/mapsfile=api&v=2&key=abcdefg&sensor=true" type="text/javascript"></script>
Upvotes: 2