Domanda

Good morning all,

I'm Danny, and I'm a Salesforce system admin and (very) junior developer currently trying to integrate Nokia's HERE maps into our system as it's public transport options are vastly superior to Google's. This is done in Salesforce with Visualforce. I've been successful in using our Enterprise id and key to call and display a route on a dynamic map, but am having some trouble with geocoding. I'm having some issues with the element below:

<head>
<script type="text/javascript" charset="UTF-8" src="https://js.cit.api.here.com/ee/2.5.3/jsl.js?with=maps,positioning,places,directions"></script>
<style type="text/css">
html {
overflow:hidden;
}

body {
margin: 0;
padding: 0;
position: absolute;
overflow:hidden;
width: 100%;
height: 100%;
}

#mapContainer {
width: 60%;
height: 95%;
left: 0;
top: 10px;
position: absolute;
}
</style>
</head>

<body>
<div id="mapContainer"></div>
<script type="text/javascript" charset="UTF-8" src="https://js.cit.api.here.com/ee/2.5.3/jsl.js?with=maps,positioning,places,directions"></script>
<script type="text/javascript"> 
nokia.Settings.set("app_id", "V6tmpXy6GHXqJWlaPVmh");
nokia.Settings.set("app_code", "XS4Tjj82QznkWAJJu0L3-g");
nokia.Settings.set("serviceMode", "cit");
(document.location.protocol == "https:") && nokia.Settings.set("secureConnection", "force");
var map = new nokia.maps.map.Display(
document.getElementById("mapContainer"), {
components: [
        new nokia.maps.map.component.ZoomBar(), 
        new nokia.maps.map.component.Behavior(),
        new nokia.maps.map.component.TypeSelector(),
        new nokia.maps.map.component.ScaleBar(),
        new nokia.maps.map.component.ContextMenu(),
    ],
});

var modes = [{
type: "fastest",
transportModes: ["car"],
trafficMode: "disabled"
}];

// GeoCode
nokia.places.search.manager.geoCode({
   searchTerm : "{!Transport_order__c.From_Address__c}",
  onComplete: onGeocodeComplete
  });

// Post GeoCode
function onGeocodeComplete(data, requestStatus) {
  var marker;
  if (requestStatus === 'OK') {
    alert('GEOCODE ENDED SUCCESSFULLY');
    marker = new nokia.maps.map.StandardMarker(data.location.position);
    map.objects.add(marker);
    map.zoomTo(marker.getBoundingBox(), false);
    if (map.get('zoomLevel') > 15) {
      map.setZoomLevel(15);
    }
  } else if (requestStatus === 'ERROR') {
    alert('GEOCODE FAILED.');
  }
}

</script>
</body>

I read from a post on this site that the Enterprise version treats nokia.places.search etc. as an instance rather than a function to be called. This makes sense, as changing the URL to SE rather than EE seems to make the geocode request run fine, however our internal system rejects the response as it's not in HTTPS (which can be forced 'on' with Enterprise).
The issue I'm having is that I'm not familiar enough with Java to truly understand what the difference is, or rather, I don't know what to do with calling upon the instance. At present, the java console in Chrome is telling me that search is an undefined type error, which isn't helpful, and I can't find any further guidance anywhere I search! Can anyone help me out in differentiating between Enterprise/ Standard guidance on this?

Thanks!

È stato utile?

Soluzione

The issue here is that there are two JavaScript APIs available, and in your case you need to be using the Enterprise Maps JS API not the public Maps JS API. The geocoding in the Enterprise Maps JS API (nokia.search.Manager) is different to the public offering and more flexible. The geocoding signature in the public Maps JS API (nokia.places.search.manager) is part of the places offering and is more restricted.

  • As an enterprise customer, the only documentation you’ll need is (pardon the pun) HERE
  • The associated set of examples can be found in the enterprise explorer
  • A geocoding example using the Enterprise Maps JS API can be found HERE, look at the code and note that it uses the nokia.search.Manager()
  • Currently Truck Routing is only available in the 6.2 enterprise routing API, whereas Public Transport routing is only available in the 7.2 routing API. This means that in order to use the public transport with the Enterprise Maps JS API, you’ll need use a nokia.maps.advrouting.Manager and contact the underlying rest service. An example of this can be found in the Community Examples
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top