admin管理员组

文章数量:1289542

How do I put the place mark on google maps?

The code below shows only particular location but I want to add my custom place mark image on google maps.

<!DOCTYPE html>
<html>
<head>
<script
src=";sensor=false">
</script>

<script>
function initialize()
{

var mapProp = {
  center:new google.maps.LatLng(23.0300,72.5800),
  zoom:5,
  mapTypeId:google.maps.MapTypeId.ROADMAP
 } 
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
}

google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>

<body>
<div id="googleMap" style="width:500px;height:380px;"></div>

</body>
</html>

How do I put the place mark on google maps?

The code below shows only particular location but I want to add my custom place mark image on google maps.

<!DOCTYPE html>
<html>
<head>
<script
src="http://maps.googleapis./maps/api/js?key=MyKey&sensor=false">
</script>

<script>
function initialize()
{

var mapProp = {
  center:new google.maps.LatLng(23.0300,72.5800),
  zoom:5,
  mapTypeId:google.maps.MapTypeId.ROADMAP
 } 
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
}

google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>

<body>
<div id="googleMap" style="width:500px;height:380px;"></div>

</body>
</html>
Share Improve this question edited Sep 19, 2013 at 7:07 Antony 15.1k10 gold badges47 silver badges76 bronze badges asked Sep 19, 2013 at 7:03 GuruGuru 6191 gold badge4 silver badges12 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

Here is an example Google Maps Marker:

var myMarker = new google.maps.Marker({
position: new google.maps.LatLng(31.1287, -94.9594117), // Example Lat/Long
map: map, // references the map object you defined earlier
title: 'My custom Title', // a title that will appear on hover
    icon: 'images/googleMap/icon-star.gif' // Optional Marker Icon to use
});

You can find out more in the Google Map Docs at Google Maps: Simple Markers

Best of luck! :)

Try this:

<!DOCTYPE html>
    <html>
    <head>
    <script
    src="http://maps.googleapis./maps/api/js?key=MyKey&sensor=false">
    </script>

    <script>
    function initialize()
    {
    var mapPin = "/path/to/image.png";
    var Marker = new google.maps.Marker({
      position: new google.maps.LatLng(23.0300,72.5800),
      map: map,
      icon: mapPin
  });
    var mapProp = {
      center:new google.maps.LatLng(23.0300,72.5800),
      zoom:5,
      mapTypeId:google.maps.MapTypeId.ROADMAP
     } 
    var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
    }

    google.maps.event.addDomListener(window, 'load', initialize);
    </script>
    </head>

    <body>
    <div id="googleMap" style="width:500px;height:380px;"></div>

    </body>
    </html>

本文标签: javascriptHow to put the place mark on google mapsStack Overflow