Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

input adresse ville automatique

<script src="https://maps.googleapis.com/maps/api/js?libraries=places&key=votre_cle_api" type="text/javascript">
Comment

input adresse ville automatique

"use strict";

// This example requires the Drawing library. Include the libraries=drawing
// parameter when you first load the API. For example:
// <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBIwzALxUPNbatRBj3Xi1Uhp0fFzwWNBkE&libraries=drawing">

  function initializeAutocomplete(id) {
        var element = document.getElementById(id);
        if (element) {
         var autocomplete = new google.maps.places.Autocomplete(element, { types: ['geocode'] });
         google.maps.event.addListener(autocomplete, 'place_changed', onPlaceChanged);
        }
      }

      // Injecte les données dans les champs du formulaire lorsqu'une adresse est sélectionnée
      function onPlaceChanged() {
        var place = this.getPlace();

        for (var i in place.address_components) {
          var component = place.address_components[i];
          for (var j in component.types) {
            var type_element = document.getElementById(component.types[j]);
            if (type_element) {
              type_element.value = component.long_name;
            }
          }
        }

        var longitude = document.getElementById("longitude");
        var latitude = document.getElementById("latitude");
        longitude.value = place.geometry.location.lng();
        latitude.value = place.geometry.location.lat();
      }

      // Initialisation du champs autocomplete
      google.maps.event.addDomListener(window, 'load', function() {
        initializeAutocomplete('user_input_autocomplete_address');
      });
Comment

input adresse ville automatique

<!DOCTYPE html>
<html>
  <head>
    <title>Drawing Tools</title>
    <script src="https://polyfill.io/v3/polyfill.min.js?features=default"></script>
       <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB66GfQcN_lknxN1jwSMo12GPva-fOMPq8&libraries=places" type="text/javascript">  </script>

    <!-- jsFiddle will insert css and js -->
  </head>
  <body>
     <form>
    <div>
      <label>Adresse</label>
      <input id="user_input_autocomplete_address" placeholder="Votre adresse...">
    </div>

    <div>
      <label>Numéro</label>
      <input id="street_number" name="street_number" disabled>
    </div>

    <div>
      <label>Route</label>
      <input id="route" name="route" disabled>
    </div>

    <div>
      <label>Code postal</label>
      <input id="postal_code" name="postal_code" disabled>
    </div>

    <div>
      <label>Ville</label>
      <input id="locality" name="locality" disabled>
    </div>

    <div>
      <label>Pays</label>
      <input id="country" name="country" disabled>
    </div>

    <div>
      <label>Latitude</label>
      <input id="latitude" name="latitude" disabled>
    </div>

    <div>
      <label>Longitude</label>
      <input id="longitude" name="longitude" disabled>
    </div>
  </form>
  </body>
</html>
Comment

PREVIOUS NEXT
Code Example
Typescript :: Pick<Pick<Pick<DetailedHTMLProps<HTMLAttributes<HTMLDivElement, HTMLDivElement 
Typescript :: typescript generic object not array 
Typescript :: DISTINQUISH BETWEEN THE AVERAGE CASE AND WORSE CASE RUNNING TIME AND THE FACTORS AFFECTING THAT AFFECTS THE RUNNING TIME OF AN ALGORITHM 
Typescript :: typescript not supporting scss 
Typescript :: inherit with filter typescript 
Typescript :: flutter allow user to select text 
Typescript :: what are the parts of an array called 
Typescript :: webots epuck line follower code 
Typescript :: create n sublists python 
Typescript :: woocommerce remove This is where you can add new products to your store in taxonomy description 
Typescript :: typescript timeout browser 
Typescript :: react dynamic inputs with id 
Typescript :: typescript interface array of dictionaries 
Typescript :: .htaccess Preventing requests with invalid characters 
Typescript :: running same test in different environment 
Typescript :: how to let a textview take 75 percent of its parent width android xml 
Typescript :: delphi call function from its name 
Typescript :: Write a prolog program to find the sum of elements in given list. 
Typescript :: extracting digits from a number in c++ 
Typescript :: how to pass data between requests 
Typescript :: graphql?query={__schema{types{name,fields{name}}}} 
Typescript :: how to get all arrangments python 
Typescript :: python unix get 5 minuts from now 
Typescript :: economic tracking portfolio construction 
Typescript :: matplotlib eats all memory when saving fig 
Typescript :: change css to scss in angular online 
Typescript :: ExtractElementByIdFromString(HTMLString, IdString) 
Typescript :: INTENT 
Typescript :: express server in vscode extension 
Typescript :: windows 10 iso 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =