No se muestra el mapa de Google Maps pero sí los controles
Frecuentes
Visto 150 veces
0
I'm fetching the coordinates from the URL that looks like this (part of it of course): weather/59.328676,13.485656
. Now, I have extract these coordinates using a function. When I am trying to load Google Maps, the controls shows but not the actual map. You can see what I mean by clicking on this link: http://server-1.myftp.org/vadret-just.nu/weather/59.328676,13.485656. The code I'm using are this:
function url_endstring(url){
return url.substr(url.lastIndexOf('/') + 1);
}
var coordinates = url_endstring(window.location.href);
var latlng = new google.maps.LatLng(coordinates);
var map_options;
var gm_map;
var marker;
function initialize() {
latlng;
map_options = {
center: latlng,
zoom: 12,
mapTypeId: google.maps.MapTypeId.ROADMAP,
streetViewControl: false,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.SMALL
}
};
gm_map = new google.maps.Map(document.getElementById('google-maps'), map_options);
marker = new google.maps.Marker({
position: latlng,
map: gm_map
});
}
Have I missed something? How can I make the Google Maps map visible?
0 Respuestas
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas javascript google-maps-api-3 or haz tu propia pregunta.
Try moving your initialize function out of the window onload event. - Alkis Kalogeris
Your code works as is.The problem may be due to css styling. - david strachan
Thanks for your answers but none of them did help me :/ My initlialize function are outside of the window onload event as I can see it. If I remove background-image from
#google-maps
in my stylesheet, only the background image disappears and a greyish background appears instead of the actual map. - AirikrWorth saying is that if I replace
var latlng = new google.maps.LatLng(coordinates);
convar latlng = new google.maps.LatLng(59.328676,13.485656);
the map shows as it should - Airikr