user3599415
user3599415

Reputation: 283

How to point out a location in google maps?

  1. Hi, i am trying to point out the location of my company. It goes to the right location but the pointer is missing. I tried alot of things but it still doesn't work. I am a beginning programmer and i need some help. Thank you for your time.

  2. This is my code:

    <jsp:include page="header.jsp">
     <jsp:param name="subTitle" value="AutoTotaalDiensten - Locatie info" />
    </jsp:include>
     </head>
     <%@ include file="menu.html"%>
    

    Locatie

     <script src="http://code.jquery.com/jquery-latest.min.js"
         type="text/javascript"></script>
      <style>
     #map_canvas {
      height: 400px;
      }
    

    <div id="map_canvas"></div>
    
    
          <script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
    
        <script>
              function initialize() {
    
          var map_canvas = document.getElementById('map_canvas');
    
              var map_options = {
    
                     var mapPin = " http://www.google.com/mapfiles/marker.png";
            var Marker = new google.maps.Marker({
    
                 center : new google.maps.LatLng(52.124707, 5.088196),  
    
                  zoom : 13,
    
    
                  mapTypeId : google.maps.MapTypeId.ROADMAP
    
    
              }
    
           var map = new google.maps.Map(map_canvas, map_options)
    
       }
    
         google.maps.event.addDomListener(window, 'load', initialize);
      </script>
    
    
      <%@ include file="footer.html"%>
    

Upvotes: 0

Views: 2428

Answers (1)

geocodezip
geocodezip

Reputation: 161334

Call Marker.setMap(map) after you initialize the map.

 function initialize() {
  var map_canvas = document.getElementById('map_canvas');
  var map_options = {
         center : new google.maps.LatLng(52.124707, 5.088196),  
         zoom : 13,
         mapTypeId : google.maps.MapTypeId.ROADMAP
  };
  var mapPin = " http://www.google.com/mapfiles/marker.png";
  var Marker = new google.maps.Marker({
         position : map_options.center,  
  });
  var map = new google.maps.Map(map_canvas, map_options)
  Marker.setMap(map);
} 
google.maps.event.addDomListener(window, 'load', initialize);

working fiddle

Or create it after you create and initailize the map and set its "map" property.

 function initialize() {
  var map_canvas = document.getElementById('map_canvas');
  var map_options = {
         center : new google.maps.LatLng(52.124707, 5.088196),  
         zoom : 13,
         mapTypeId : google.maps.MapTypeId.ROADMAP
  };
  var mapPin = " http://www.google.com/mapfiles/marker.png";
  var map = new google.maps.Map(map_canvas, map_options)
  var Marker = new google.maps.Marker({
         map: map,
         position: map.getCenter()
  });
} 
google.maps.event.addDomListener(window, 'load', initialize);

working fiddle

Upvotes: 2

Related Questions