Jump to content
SiteSniffer

[Google Maps] marker + balloon

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.

Share this post


Link to post
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);	  }    });  }

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...