-2

I'm creating google map this way.

function initialize() {
        var map_canvas = document.getElementById('map');
        var map_options = {
          center: new google.maps.LatLng(55.684374, 37.849364),
          zoom: 16,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        }
        var map = new google.maps.Map(map_canvas, map_options)
      }
      google.maps.event.addDomListener(window, 'load', initialize);

How i can put marker on map, on place i want?

Thanks

1 Answers1

0

I suggest you to define LatLng outside of map_options.

var myLat = new google.maps.LatLng(55.684374, 37.849364)

Inside map_options you can pass myLat to center

You already have a map property var map = new google.maps.Map(map_canvas, map_options). You can use that property and create new Marker

var marker = new google.maps.Marker({ position: myLat, map: map, title:"Hello World!" });

For more informations please consult this

radubogdan
  • 2,744
  • 1
  • 19
  • 27