Google Maps Integration on Website

I want to create a web application that will get 2 places and their zip code and show the result on google map. For example, I select 2 cities or a country and show a road map with a colored line according to my points.

+3
source share
2 answers

Best Place to Search - Google Maps API V3 Documentation - I recommend V3 as they no longer support V2

Basic documentation: http://code.google.com/apis/maps/documentation/javascript/

Samples: http://code.google.com/apis/maps/documentation/javascript/examples/index.html

: http://code.google.com/apis/maps/documentation/javascript/examples/directions-simple.html

, , API, google , . , !

+3

location.html

<!DOCTYPE html> 
<html> 
  <head> 
    <title>Google Maps JavaScript API v3 Example: Map Geolocation</title> 
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> 
    <meta charset="UTF-8"> 
    <link href="map.css" rel="stylesheet" type="text/css"> 
<!--
Include the maps javascript with sensor=true because this code is using a
sensor (a GPS locator) to determine the user location.
See: http://code.google.com/apis/maps/documentation/javascript/basics.html#SpecifyingSensor
--> 
<script type="text/javascript"
    src="http://maps.googleapis.com/maps/api/js?sensor=false"></script> 

<script type="text/javascript"> 
var siberia = new google.maps.LatLng(37.625364,-122.423905);

function initialize() {
  var myOptions = {
    zoom:19,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };
  var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
  var infowindow = new google.maps.InfoWindow({
          map: map,
          position: siberia,
          content: 'Location found using HTML5.'
        });

  var marker =  new google.maps.Marker({
    position: siberia,
    map: map,
    title: "omt"
  });
  map.setCenter(siberia);

}
  google.maps.event.addDomListener(window, 'load', initialize);
    </script> 
  </head> 
  <body> 
    <div id="map_canvas"></div> 
  </body> 
</html> 

map.css

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

#map_canvas {
  height: 100%;
}

@media print {
  html, body {
    height: auto;
  }

#map_canvas {
height: 650px;
}
}
+2

Source: https://habr.com/ru/post/1796210/


All Articles