Errors map with leaflet and google

1

Good, I have a couple of failures that bring me head (against the wall), to see if you can throw a handle ...

The first one is that the autocompletar of google works for me when he feels like it, there are streets that take them perfect and others that he puts them in the middle of nowhere or that they return "Spain" and peta all xD In the Select that is displayed, the directions are fine but when you press a boom! peta ...

The other error that can also be seen in the photos, is that the market does not coincide with the start / end of the route

I do not know what to do anymore so I ask u.u the map is made with a leaflet with a google layer and pulls the autocomplete google to put the directions and take the routes. It's a lot of xD code so I do not know how to put it or what to put because I do not know where the fault is

I hope you can help me a little bit, I am very stuck with this. Thanks

EDITING ---- I think that the markers could be because I create them simply in the coordinates in which they are played, without looking if it is in the middle of a street or the sea hehe but I do not know how to control that they believe in the street, which is what controls the API for the routes.

if($scope.markers.length == 0){
 createOriginMarker(leafEvent.latlng.lat,leafEvent.latlng.lng);

 originLocation = {latitude:leafEvent.latlng.lat ,longitude:leafEvent.latlng.lng};
 reverseGeocode(originLocation, 0);
 fitMap();

}else if ($scope.markers.length == 1){        createDestMarker(leafEvent.latlng.lat,leafEvent.latlng.lng)

      destLocation = {latitude:leafEvent.latlng.lat,longitude:leafEvent.latlng.lng};
      reverseGeocode(destLocation, 1);
      fitMap();
      //Get int routes && save address
      getIntRoutes();
      //Finalizar listener con el ultimo marker
      clickMapEvent();
    }

This is where I create the markers

And this is where the autocomplete event is, in the console log it gives me the same erroneous address as the final result

$scope.$on('g-places-autocomplete:select', function (event, param, a, b) {
    console.log("format adress: " + param.formatted_address);
    $scope.searchForIntRoutes();
  });
<div id="searchView" ng-if="searchViewControl">
        <div class="list">
          <div class="item mapInput">
            <img src="img/icon-start-48.png" class="icon placeholder-icon">
            <input g-places-autocomplete  name="origen" id="origen"  type="text"  placeholder="Origin" ng-model="data.origin" required>
          </div>

          <div class="item mapInput">
            <img src="img/icon-end-48.png" class="icon placeholder-icon">
            <input g-places-autocomplete name="destino" id="destino" type="text"  placeholder="Destination" ng-model="data.dest" required>
          </div>
        </div>
      </div> 
    
asked by Anntrick 29.06.2016 в 09:22
source

1 answer

1

I have managed to correct the error of the markers, it turns out that the coordinate points to the upper left corner of the image, I just had to adjust that in the leaflet css .. and in passing I have added a function that redirects the marker to the street closest to where you press.

But I still can not fix the autocomplete, please if someone understands this, tell me what can be = (

Thanks

    
answered by 04.07.2016 в 08:46