Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put the place mark on google maps?

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.com/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>
like image 467
Guru Avatar asked Nov 30 '25 14:11

Guru


2 Answers

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! :)

like image 118
TheIronDeveloper Avatar answered Dec 03 '25 03:12

TheIronDeveloper


Try this:

<!DOCTYPE html>
    <html>
    <head>
    <script
    src="http://maps.googleapis.com/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>
like image 40
jono Avatar answered Dec 03 '25 04:12

jono



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!