Показать сообщение отдельно
  #4 (permalink)  
Старый 18.05.2019, 19:28
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,068

Vladiiimir,
<html>
  <head>
    <title>Simple Map</title>
    <meta charset="utf-8">
    <style>
      /* Always set the map height explicitly to define the size of the div
       * element that contains the map. */
      #map {
        height: 50%;
      }
      /* Optional: Makes the sample page fill the window. */
      html, body {
        height: 100%;
        margin: 0;
        padding: 0;
      }
    </style>

     <script>

var map, marker;

function initMap() {
    map = new google.maps.Map(document.getElementById("map"), {
        center: new google.maps.LatLng(51.754207,55.106578),
        zoom: 8
    });
}

function UpdateGoogleMap(latitude, longitude) {
    latitude = (latitude && +latitude)||51.754207;
    longitude = (longitude && +longitude)||55.106578;
    map.setCenter({
        lat: latitude,
        lng: longitude
    });
    marker && marker.setMap(null);
    marker = new google.maps.Marker({
        position: {
            lat: latitude,
            lng: longitude
        },
        map: map,
        title: "Это здесь"
    });
};

</script>
      <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCWH__g2XMzhes7PIk-8v2MbBSZTgMnBSg&callback=initMap"
      async defer></script>
  </head>
  <body>
        <form name="info">
                Широта: <input type="text" name="xfirst" align="left" size=20 ><br><br>
                Долгота: <input type="text" name="xend" align="left" size=20 ><br><br>

                <input type="button" value="Построить" name="buttonDraw" align="center" size=15 onclick="UpdateGoogleMap(xfirst.value,xend.value)"><br>
        </form>

        <div id="map">
        </div>

  </body>
</html>
Ответить с цитированием