Skip to content
Dmytro Verbovyi edited this page Dec 7, 2018 · 3 revisions

Map-ready event

Use the map-ready callback to get an object with public API.

    //@param {Object} heremaps - directive object with public API

    $scope.onMapReady = function(heremaps){
         ...
    }
    <div heremaps controls events
         options="mapOptions"
         places="markers" 
         map-ready="onMapReady">
    </div>

Directive public API

The API available from argument object of the map-ready callback.

    heremaps.setCenter({
        lat: 52.508249, 
        lng: 13.33893
    })

Navigate to a specific place, setting it to the map center.


    heremaps.getCenter()

    /*@returns {Object}
        @property {Number} lat - latitude
        @property {Number} lng - longitude
    */

Get current map center


    heremaps.setZoom(15)

Set map zoom value


    heremaps.getZoom()
    
    //@returns {Number}

Get current zoom-level


   //@param {H.geo.Rect} bounds - https://developer.here.com/documentation/maps/topics_api/h-geo-rect.html

   heremaps.setViewBounds(bounds)

Fit map zoom into bounds


    heremaps.getViewBounds()
   
    //@returns {H.geo.Rect} - https://developer.here.com/documentation/maps/topics_api/h-geo-rect.html

Get current map viewBounds


    heremaps.getBoundsReactFromPoints(topLeftPoint, bottomRightPoint);
   
    //@returns {H.geo.Rect} - https://developer.here.com/documentation/maps/topics_api/h-geo-rect.html

Get view bounds rectangle object from lat-lng points

Example:

    function setViewBoundsByPoints(heremaps) {
        var topLeftPoint = { lng: 55.1021576, lat: 25.064732 };
        var bottomRightPoint = { lng: 54.1021576, lat: 24.064732 };
    
        var bounds = heremaps.getBoundsReactFromPoints(topLeftPoint, bottomRightPoint);
    
        heremaps.setViewBounds(bounds);
    }

    $scope.onMapready = function(heremaps) {
        setViewBoundsByPoints(heremaps);
    }

    heremaps.refresh()

Re-initialize map according to new sizes and refresh viewBounds


Other available API methods

Docs in progress. Please, currently use signatures examples https://github.com/dverbovyi/angular-heremaps/blob/master/src/heremaps.directive.js#L185 or ask any questions

  • calculateRoute
  • addRouteToMap
  • cleanRoutes
  • getUserLocation
  • geocodePosition
  • geocodeAddress
  • geocodeAutocomplete
  • findLocationById
  • updateMarkers

Also, you can directly get all Here Maps instances and additionally customize them according to your requirements using official Here Maps documentation

    heremaps.getPlatform()

Returns Here Maps instances

Clone this wiki locally