Geocoding

4 posts / 0 new
Last post
joshua.gill
Geocoding

I don't seem to be able to get the geocoder to work, any help would be appreciated - I suspect I'm missing something obvious.

I have

<script src="https://api.mqcdn.com/sdk/mapquest-js/v1.3.2/mapquest-maps.js"></script>

in my index.html and am using

L.mapquest.geocoding().geocode('someValue');

in my javascript (I'm using Angular 4). L.mapquest is defined, and I can see the map, but from what I can tell from the documentation there should be a geocoding function on the mapquest object. However, I get this console error:

TypeError: L.mapquest.geocoding is not a function

Does the geocoder have some other requirement?

Thanks in advance,

Josh


MQBrianCoakley
Assuming you also have the
Assuming you also have the css connected, it looks like you have everything you need. This should cover a simple version of what you need to do to geocode within MapQuest.js. Unless another script tag has overwritten the MapQuest.js tag, or parts of it, you should be good to go.

MDS
Geocoding with an Advanced Location Object

This is the code, in principle it worked perfect, and after trying to load the address with PHP it stopped working, even when you erase the code and put the address back by hand. What can be?

<html>
  <head>
    <script src="https://api.mqcdn.com/sdk/mapquest-js/v1.3.2/mapquest.js"></script>
    <link type="text/css" rel="stylesheet" href="https://api.mqcdn.com/sdk/mapquest-js/v1.3.2/mapquest.css"/>

    <script type="text/javascript">
      window.onload = function() {
        L.mapquest.key = 'lYrP4vF3Uk5zgTiGGuEzQGwGIVDGuy24';

        L.mapquest.geocoding().geocode({
          street: '52 azul',
          city: 'Buenos Aires',
          state: '',
          postalCode: '1407'
        }, createMap);

        function createMap(error, response) {
          var location = response.results[0].locations[0];
          var latLng = location.displayLatLng;
          var map = L.mapquest.map('map', {
            center: latLng,
            layers: L.mapquest.tileLayer('map'),
            zoom: 18
          });
        }
      }
    </script>
  </head>

  <body style="border: 0; margin: 0;">
    <div id="map" style="width: 100%; height: 530px;"></div>
  </body>
</html>


MQBrianCoakley
What is the resulting html
What is the resulting html/javascript from the PHP that is not working? Is the address, html, javascript, or anything else different when coming from the PHP? I've done almost zero PHP so I won't be much, if any, help with that.