Monday, May 20, 2024
19
rated 0 times [  21] [ 2]  / answers: 1 / hits: 38545  / 12 Years ago, fri, february 22, 2013, 12:00:00

The marker isnt showing up, i read the docs but i cant find the problem, can somebody help me plz?



heres the js:



function initialize() {
var mapOptions = {
center: new google.maps.LatLng(-8.064903, -34.896872),
zoom: 16,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById(map_canvas), mapOptions);

var marker = new google.maps.Marker({
position: location,
title:Hello World!,
visible: true
});
marker.setMap(map);
}

More From » google-maps-api-3

 Answers
2

My guess is that your location object is not defined. Try setting your marker position to the same LatLng as your map center and see if it works:



function initialize() {
latLng = new google.maps.LatLng(-8.064903, -34.896872)
var mapOptions = {
center: latLng,
zoom: 16,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById(map_canvas), mapOptions);

var marker = new google.maps.Marker({
position: latLng,
title:Hello World!,
visible: true
});
marker.setMap(map);
}

[#80064] Thursday, February 21, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
madelyn

Total Points: 449
Total Questions: 100
Total Answers: 100

Location: Seychelles
Member since Fri, May 7, 2021
3 Years ago
madelyn questions
Wed, Jul 28, 21, 00:00, 3 Years ago
Wed, Jul 14, 21, 00:00, 3 Years ago
Sat, Nov 7, 20, 00:00, 4 Years ago
Thu, Sep 3, 20, 00:00, 4 Years ago
;