×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Aug 2013
    Posts
    3

    Is there GeoJSON support for Here Maps or any alternative to KML

    Is it possible to load GeoJson formatted data into here maps js api in a proper way? I am using AJAX to send data coming from mysql which is formatted in GeoJSON. I don't want to store any kml files.

  2. #2
    Nokia Developer Moderator
    Join Date
    Aug 2011
    Location
    Berlin
    Posts
    288

    Re: Is there GeoJSON support for Here Maps or any alternative to KML

    There is no GeoJson Parser in the API. You'll need to write your own. Taking the basis from an equivalent parser for Google maps, I've knocked up the following:

    https://github.com/heremaps/examples...json-parser.js

    The basic usage of the GeoJSONContainer is through the parseGeoJSON() method as follows:

    Code:
    function extend(B, A) {
    	function I() {}
    	I.prototype = A.prototype;
    	B.prototype = new I();
    	B.prototype.constructor = B;
    }
    
    function createGeoJsonParser(){
    	extend(GeoJSONContainer, nokia.maps.map.Container);
    	parser = new GeoJSONContainer();
    
    }
    
    function parseJson(jsonObject){
    
    	result = parser.parseGeoJSON(jsonObject);	
    	if (parser.state == "finished") {
    		map.objects.addAll(result);
    		map.set("center", map.objects.get(0).getBoundingBox().getCenter());
    		
    		map.addListener("click" ,  function(evt) {
    			var text = JSON.stringify(evt.target.properties);
    			bubble = infoBubbles.addBubble(text!== undefined ?   text : "properties undefined",
    				 evt.target.getBoundingBox().getCenter());
    		}, false);
    	} else {
    		console.log(result);
    	}
    }
    see: http://rawgithub.com/heremaps/exampl...json-data.html

    Since GeoJSONContainer is an extension of Container, you could also add the geoJSON data directly onto the map using addGeoJSON()

    Code:
    var err = resultSet.addGeoJSON(jsonManager.object);
    if (resultSet.state == "finished") {
    	map.zoomTo(container.getBoundingBox());
    	container.addListener("click" ,  function(evt) {
    		infoBubbles.addBubble(evt.target.properties.Description,
    		 evt.target.getBoundingBox().getCenter());
    	}, false);
    } else {
    	alert(err);
    }
    Example Use: http://rawgithub.com/heremaps/exampl...sing-ajax.html


    you can alos add and style data points in the same manner as the clustering component
    Examples:




    It comes with no guarantees of course.
    Last edited by jasfox; 2013-09-04 at 13:41.

Similar Threads

  1. Ovi Maps API support for Mango
    By Maveric in forum Windows Phone General
    Replies: 17
    Last Post: 2012-03-26, 16:48
  2. alternative to ovi maps sdk
    By djpalshikar in forum [Closed] Publishing to Nokia Store
    Replies: 1
    Last Post: 2010-08-28, 06:32
  3. Replies: 5
    Last Post: 2009-08-29, 16:12
  4. Replies: 1
    Last Post: 2009-05-25, 04:47

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •