GoogleMaps Api and C#-Collection of common programming errors
i have problem with my map. Map was working correctly about 5 months ago. Now when I load map with my coords, map is loading, but when i start browsing map, zooming etc. i’m getting white screen like there’s no connection with map.. i need to load map again, but again this same problem happens. About 5 months ago i was using this script and everything was working fine.. browsing, zooming, change map type, everything without any problems. I’ve created html code according to google website and put it in new resource file:
Google Maps JavaScript API v3 Example: Map Simple
function load(latitude,longitude,zoomik) {
var myLatlng = new google.maps.LatLng(latitude,longitude);
var myOptions = {
zoom: zoomik,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title:"Here!"});
}
Code for my button is:
private void TestButton_Click(object sender, EventArgs e)
{
webBrowser1.Document.InvokeScript("load", new object[] { -34.397, 150.644, 8 });
}
Screens: Map loaded correctly:
After use of pan tool or zoom tool: – blank white screen.
I’m using Visual C# Express and WebBrowser control from winforms.
HTML code is working correctly in Firefox (using Aptana Studio) (zoom and pan working ok)
What more this code from google api example is also not working correctly:
Google Maps JavaScript API v3 Example: Map Simple
function initialize() {
var myLatlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 8,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
-
I’ve figured this myself.
Wrong was:
after changing it to:
map is working as it should.
-
When i have problems with gMaps the first thing i do is changing the map key, did you try this? Which browsers did you try? Firefox, Chrome or IE ?