In the previous post, I had shown you how to embed a simple map to the web page. In this post, I will let you know how to add an marker to the map.
The marker object resides in the google.maps.Marker
namespace and takes a single argument, options. Options is an object literal called Marker options
that can have several properties of which two are required:
- map
Map is a reference to the map where you want to add the marker. - position
This property indicates the location of the marker and is of typegoogle.maps.LatLng
var latlng = new google.maps.LatLng(10.823099, 106.629664);
var myOptions =
{
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var marker = new google.maps.Marker({
position: new google.maps.LatLng(10.823099, 106.629664),
map: map
});
Hope this helps!
Read more:
0 comments:
Post a Comment