2014-11-26 3 views
-1

나는 자바 스크립트의 초보자입니다. 맵에 마커를 추가하고 싶습니다. 지금 내가 어떻게 할 수 있니?Google지도에 마커를 추가하는 방법 - javascript

나는이 위치를 설정하려면 : LatLng(35.738943, 51.326078);

내지도 :

var marker = new google.maps.Marker({ 
     position: myLatlng, 
     map: map, 
     title: name 
    }); 

이 무엇 전체 코드는 것입니다 : 당신이지도를 만든 후

<script type="text/javascript"> 
     // When the window has finished loading create our google map below 
     google.maps.event.addDomListener(window, 'load', init); 

     function init() { 
      // Basic options for a simple Google Map 
      // For more options see: https://developers.google.com/maps/documentation/javascript/reference#MapOptions 
      var mapOptions = { 
       // How zoomed in you want the map to start at (always required) 
       zoom: 17, 

       // The latitude and longitude to center the map (always required) 
       center: new google.maps.LatLng(35.738943, 51.326078), 

       // How you would like to style the map. 
       // This is where you would paste any style found on Snazzy Maps. 
       styles: [ {  featureType:"all",  elementType:"all",  stylers:[  {   invert_lightness:true  },  {   saturation:10  },  {   lightness:30  },  {   gamma:0.5  },  {   hue:"#1C705B"  }  ] } ] 
      }; 

      // Get the HTML DOM element that will contain your map 
      // We are using a div with id="map" seen below in the <body> 
      var mapElement = document.getElementById('map'); 

      // Create the Google Map using out element and options defined above 
      var map = new google.maps.Map(mapElement, mapOptions); 
     } 
    </script> 
    <script src="js/wow.min.js"></script> 
<script> 
wow = new WOW(
{ 

    } ) 
    .init(); 
</script> 
+0

https://developers.google.com/maps/documentation/javascript/examples/marker-simple – geocodezip

답변

0
var lat = "35.738943"; 
var lng = "51.326078"; 
var name = "My place"; 

var myLatlng = new google.maps.LatLng(lat,lng); 

오른쪽 아마도 모양을

google.maps.event.addDomListener(window, 'load', init); 

     function init() { 

      var lat = "35.738943"; 
      var lng= "51.326078"; 
      var name = "My place"; 

      var myLatlng = new google.maps.LatLng(lat,lng); 

      var mapOptions = {     
       zoom: 17, 
       center: new google.maps.LatLng(35.738943, 51.326078),     
       styles: [ {  featureType:"all",  elementType:"all",  stylers:[  {   invert_lightness:true  },  {   saturation:10  },  {   lightness:30  },  {   gamma:0.5  },  {   hue:"#1C705B"  }  ] } ] 
      }; 

      var mapElement = document.getElementById('map'); 

      var map = new google.maps.Map(mapElement, mapOptions); 

      var marker = new google.maps.Marker({ 
       position: myLatlng, 
       map: map, 
       title: name 
      }); 
+0

정확한 답변에 대한 의견이 없습니다. –

+0

나는 downvote하지 않았지만, 그것이 작동하지 않는 것처럼 내게 보인다. 당신의 답을 시험 했습니까? 나는 그것이 작동하지 못하게하는 한 오타를 보았습니다 ('var long = "51.326078";를 정의하지만, 코드는 lng를 사용합니다). – geocodezip

+0

나는 downvote하지 않았지만 작동하지 않습니다 ... –

관련 문제