www.webdeveloper.com
Results 1 to 3 of 3

Thread: Problem placing a market and specifiying position on a map using google maps api

  1. #1
    Join Date
    Feb 2014
    Posts
    23

    Problem placing a market and specifiying position on a map using google maps api

    Okay, so I am pretty new to all of this and I am trying to get a marker to be placed at a specific lat longitude when a map is loaded. Here is my code:

    Code:
    function initialize() {
        var map_canvas = document.getElementById('map_canvas');
    	var myLatlng = new google.maps.LatLng(39.960478,-75.603013);
        var map_options = {
          center: myLatlng,
          zoom: 20,
    	  mapTypeControl: true,
    	  mapTypeControlOptions: {
          style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR
        },
        zoomControl: true,
        zoomControlOptions: {
          style: google.maps.ZoomControlStyle.LARGE
        },
          mapTypeId: google.maps.MapTypeId.ROADMAP
        }
        
      }
      var map = new google.maps.Map(document.getElementById("map_canvas"), map_options);
      var marker = new google.maps.Marker({
    	position: myLatlng,
    	map: map
    	});
      google.maps.event.addDomListener(window, 'load', initialize);
    unfortunetly now when i refresh the browser nothing loads, I used this tutorial: https://developers.google.com/maps/d...script/markers
    thanks guys

  2. #2
    Join Date
    Feb 2014
    Posts
    23
    eh I figured it out, I overlooked placing the marker variable into the defined map variable

  3. #3
    Join Date
    Feb 2014
    Location
    Managua, Nicaragua
    Posts
    38
    Use this code:

    Code:
    <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 = {
    		center: new google.maps.LatLng(29.861609,-95.648529), //You have to use your own coordinates
    		zoom: 17,
    		mapTypeId: google.maps.MapTypeId.ROADMAP
    	}
    	var map = new google.maps.Map(map_canvas, map_options)
    }
    google.maps.event.addDomListener(window, 'load', initialize);
    </script>
    <div id="map_canvas"></div>
    See the example working at http://jandjshinecleaning.net/contact/

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles