Display Marker Information

430 views
Skip to first unread message

Sandy

unread,
Feb 24, 2011, 5:13:08 AM2/24/11
to Google Maps JavaScript API v3
It Displays the informatio of the latest marker added.If i want to
display the previous marker information. How should i do it?


<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0px; padding: 0px }
#map_canvas { height: 100% }
</style>
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=true">
</script>
<script type="text/javascript">
var map,marker;
function initialize() {
var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
var myOptions = {
zoom: 12,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
//alert(myOptions.zoom);
map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
var html="<p>Hello</p>";
infowindow=new google.maps.InfoWindow({content:html});
google.maps.event.addListener(map, "click", function(event) {
marker = new google.maps.Marker({
position: event.latLng,
map: map,
clickable:true
});
google.maps.event.addListener(marker, "click", function() {
infowindow.open(map, marker);
});
});
}

function placeMarker(location) {
marker = new google.maps.Marker({
position: location,
map: map

});
//alert(location.lat());
//map.setCenter(location);
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="margin-left:100px;width:500px; height:
100%"></div>
</body>
</html>

Andrew Leach

unread,
Feb 24, 2011, 5:17:16 AM2/24/11
to google-map...@googlegroups.com
On 24 February 2011 10:13, Sandy <sandyri...@gmail.com> wrote:
> It Displays the informatio of the latest marker added.If i want to
> display the previous marker information. How should i do it?

You have fallen into Pitfall Number Three.

You should use a helper function to create your markers:
http://www.geocodezip.com/v3_MW_example_map1.html

Sandy

unread,
Feb 25, 2011, 2:51:40 AM2/25/11
to Google Maps JavaScript API v3
Actuall i want to create a page in which a user clicks on the map a
marker will be created and the user will be given a infowindow...Now i
want to implement a page in which he will save what kind of marker was
dat?
Unless he clicks on the save button or cancel.He wont be able to click
on the map...

http://code.google.com/apis/maps/articles/phpsqlinfo_v3.html

Pls help

geoco...@gmail.com

unread,
Feb 25, 2011, 6:18:37 AM2/25/11
to Google Maps JavaScript API v3
Please demonstrate the problem on your map.

-- Larry
Reply all
Reply to author
Forward
0 new messages