Add map with search service using Angularjs and google maps

Asked

Viewed 343 times

2

I have a map and wish that it can be located and marked a certain point by the address passed by the user. Example: The user types : rua são joão,403, São Paulo, Sp. The map must return the point on the map referring to the given address. html

<script src="https://maps.googleapis.com/maps/api/js?libraries=places&sensor=false&key=AIzaSyDij4Z3AFhetKwsKd9dP6gd0jPceh4Y70I"></script>
<ui-gmap-google-map center="map.center" zoom="map.zoom" events="map_events">
    <ui-gmap-marker idkey="123" coords="unit.coordinates" options="{ draggable: true }" events="marker_events"></ui-gmap-marker>
  </ui-gmap-google-map>

js

app.config(function(uiGmapGoogleMapApiProvider) {
  uiGmapGoogleMapApiProvider.configure({
    key: 'AIzaSyDij4Z3AFhetKwsKd9dP6gd0jPceh4Y70I',
    v: '3.20',
    libraries: 'places,weather,geometry,visualization'
  });
});

<!-- begin snippet: js hide: false console: true babel: false -->

I want to enable the search there and I’m not getting.

1 answer

0

Use the Geocode API.

http://maps.google.com/maps/api/geocode/json?address=rua são joão,403, São Paulo, Sp

Returns an object that contains even the property geometry.location : { "lat" : -23.4346994, "lng" : -46.7748177}.

Source.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.