rohitarora
rohitarora

Reputation: 1365

google maps display with location like https://maps.google.com/maps?q=loc:28.617885999999999,77.372363000000007

how can we use

https://maps.google.com/maps?q=loc:28.617885999999999,77.372363000000007

directly in out html using iframe or something else.and i also want to diplay location like its showing A in it

or you can help me to use javascript api like https://developers.google.com/maps/documentation/javascript/tutorial

i used it but not showing location mark like A in previous

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
      html { height: 100% }
      body { height: 100%; margin: 0; padding: 0 }
      #map_canvas { height: 100% }
    </style>
    <script type="text/javascript"
      src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&sensor=false">
    </script>
    <script type="text/javascript">
      function initialize() {
        var mapOptions = {
          center: new google.maps.LatLng(28.617885999999999, 77.372363000000007),
          zoom: 8,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("map_canvas"),
            mapOptions);
      }
    </script>
  </head>
  <body onload="initialize()">
    <div id="map_canvas" style="width:100%; height:100%"></div>
  </body>
</html>

Please help thx in advance

Upvotes: 0

Views: 628

Answers (2)

geocodezip
geocodezip

Reputation: 161334

Without using the geocoder:

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
      html { height: 100% }
      body { height: 100%; margin: 0; padding: 0 }
      #map_canvas { height: 100% }
    </style>
    <script type="text/javascript"
      src="https://maps.googleapis.com/maps/api/js?&sensor=false">
    </script>
    <script type="text/javascript">

  var map;
  function initialize() {
    var Lat = 28.617885999999999;
    var Long = 77.372363000000007;
    var latlng = new google.maps.LatLng(Lat, Long);
    var mapOptions = {
      zoom: 12,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);

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

    </script>
  </head>
  <body onload="initialize()">
    <div id="map_canvas" style="width: 100%; height: 100%;"></div>
  </body>
</html>

Upvotes: 1

rohitarora
rohitarora

Reputation: 1365

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
      html { height: 100% }
      body { height: 100%; margin: 0; padding: 0 }
      #map_canvas { height: 100% }
    </style>
    <script type="text/javascript"
      src="https://maps.googleapis.com/maps/api/js?&sensor=false">
    </script>
    <script type="text/javascript">
      var geocoder;
  var map;
  function initialize() {
    geocoder = new google.maps.Geocoder();
    var Lat = 28.617885999999999;
    var Long = 77.372363000000007;
    var latlng = new google.maps.LatLng(Lat, Long);
    var mapOptions = {
      zoom: 12,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
    var address = Lat+', '+Long;
    geocoder.geocode( { 'address': address}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        map.setCenter(results[0].geometry.location);
        var marker = new google.maps.Marker({
            map: map,
            position: results[0].geometry.location
        });
      } else {
        alert("Sorry no recent location");
      }
    });
  }

    </script>
  </head>
  <body onload="initialize()">
    <div id="map_canvas" style="width: 100%; height: 100%;"></div>
  </body>
</html>

did it with my own self thanx by the way

Upvotes: 0

Related Questions