Jump to content

[Google Maps] marker + balloon


SiteSniffer

Recommended Posts

I'm trying to get a marker on the location with a small text-balloon, displaying the location name (manually set). Sofar I came up empty handed when it comes to searching on Google trying to find a solution. Here's my working code sofar:

    <script type="text/javascript"src="http://maps.googleapis.com/maps/api/js?&sensor=false"></script>    <script type="text/javascript">	  function initialize()          {            var myOptions = {                                center: new google.maps.LatLng(my.coords, go.here),                                zoom: 16,mapTypeId: google.maps.MapTypeId.ROADMAP                            };            var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);          }    </script>

Can somebody help me out with the marker and the balloon please? Tia.

Link to comment
Share on other sites

You mean marker and text box like this?

window.onload=function(){initialize();}var geocoder;  var map;  var infowindow = new google.maps.InfoWindow();  var marker;  function initialize() {    geocoder = new google.maps.Geocoder();    latlng = new google.maps.LatLng(40.730885,-73.997383);    var myOptions = {	  zoom: 8,	  center: latlng,	  mapTypeId: 'roadmap'    }    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);    codeLatLng();  }  function codeLatLng() {    var addr = "40.730885,-73.997383";    var mydescrip ="blah blah blah";    var latlngStr = addr.split(",",2);    var lat = parseFloat(latlngStr[0]);    var lng = parseFloat(latlngStr[1]);    var latlng = new google.maps.LatLng(lat, lng);    geocoder.geocode({'latLng': latlng}, function(results, status) {	  if (status == google.maps.GeocoderStatus.OK) {	    if (results[1]) {		  map.setZoom(11);		  marker = new google.maps.Marker({			  position: latlng,			  map: map		  });		  //infowindow.setContent(results[1].formatted_address);          infowindow.setContent(mydescrip);          mydescrip		  infowindow.open(map, marker);	    } else {		  alert("No results found");	    }	  } else {	    alert("Geocoder failed due to: " + status);	  }    });  }

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...