Adding SVG overlay to nokia HERE map - svg

I'm working with nokia HERE maps and I want to add an additional layer of visualization graphics on top of a map. Since the possibilities to interact, manipulate and customize the graphics created by the HERE api are limited, I would like to work with d3.js/SVG for my visualizations.
My straight forward and obvious solution would have been to just add an absolute positioned SVG element on top of the map and giving it the same dimensions. But of course that takes every possibility to interact with the map. Is there any solution to add an overlay to the map which allows me to put SVG on it while maintaining the full interactivity (panning, zooming, clicking) of the map? Also it should be possible to interact with the SVG.
I know that there is a possibility to add a custom overlay of tiles provided by a tile server to HERE maps but that's not really what I'm looking for. I'm looking for something like the solution google has to offer to this problem. A set of custom layers which are always in sync with the corresponding map and have their own initialize, draw and remove methods. Is there something similar for HERE maps?

I think you are after the nokia.maps.map.provider.CanvasProvider class. This class provides a ground overlay bound to a specific area which offers a draw() method. The attach() method is the equivalent of your intialize I think, and you can refresh the overlay using update().
Depending upon your use case, I've also found the following techniques useful regarding SVG, Images and HERE Maps:
For an SVG marker which is anchored to a point and doesn't resize
use: SVG Markers
Alternatively override the Marker class and write using the low
level graphics commands to add flexibility to the rendering of a
marker anchored to a point. Like this: Defaced Marker
To add an image bound to a specific area use the ImageProvider class
To add a series of tiled images from a TMS (Tile Map Service) use the ImgTileProvider class
Alternatively if the [zoom][col][row] is useful to you and you
want to write SVG based stuff yourself try something like this example - which combines
SVG with 256x256 pixel markers.
Note that the HERE Maps API for JavaScript only supports SVG Tiny.

A class like the old nokia.maps.map.provider.CanvasProvider isn't even available on the new v3 API from Here.
Your best bet is on Leaflet using custom providers loading Here map tiles. Then you just load this Custom Overlay class and you're all set to draw D3, WebGL, whatever you need. Leaflet only loads the tiles from the providers and exposes some simple APIs. You will not have to deal with any of the providers' APIs.
Just don't forget to add your app_id and app_code to the provider class.

Related

How to draw custom shapes with draw2d?

I am using draw2d javascript library for drawing predefined shapes and custom shapes in it's canvas.
As I don't have any example made yet, I am trying to copy from it's documentation but doesn't seem to find a good way to research it as it contains a whole lot of it.
Here is the circle example.
http://www.draw2d.org/draw2d_touch/jsdoc_6/#!/api/draw2d.shape.basic.Circle
and here are some more documentation with examples.
http://www.draw2d.org/draw2d_touch/jsdoc_6/
I have premade shapes with html and css and I am trying to drag and drop and render them on canvas like these in this image. Also when dropped, they should have input and output ports too.
Is it possible to convert this html/css to draw2d shapes?
So here this is made possible via extending draw2d's SVGFigure and thus we have ability to provide custom svg to render it as a custom shape.
Below links were useful in this context.
http://www.draw2d.org/draw2d_touch/jsdoc/#!/guide/extending_svg_figure-section-live-example
https://github.com/freegroup/draw2d/tree/master/examples/shape_custom_svg
http://www.draw2d.org/draw2d_touch/jsdoc_6/#!/api/draw2d.SetFigure
https://github.com/freegroup/draw2d/tree/master/examples/shape_labeld
https://github.com/freegroup/draw2d/tree/master/examples/shape_custom_markdown

Cross-Platform Vector Format

Does there exist a data (file?) format representing a resizable vector graphic that can be exported to iOS CoreGraphics AND be rendered on a Linux server? I've been considering SVG with this library, but I need support for text and element constraints (i.e. pinning elements to edges).
I am not aware of a file format that provides the functionality that you are looking for out of the box.
But you may want to consider using SVG in combination with Paper.js. In Paper.js you can add custom data to any item (http://paperjs.org/reference/item/#data). Using Javascript you can then interpret the data and use it for applying your constraints prior to rendering.
Please note that while Paper.js is quite good for doing layout of elements (applying your constraints should be easy) and it has SVG import and export, but it does not support the full SVG spec (especially filters are missing).

Undirected graph using Raphael layouted using Jointjs

I am trying to create an undirected graph in Raphael (unsuccessful till now) and layout it using JointJs. I am able to create an undirected graph in JointJs and layout it.
From past couple of days i have been going through Raphael documentation, did a local setup but struggling to create a graph. My basic requirement is diagramming/graph creation through Raphael and rendering it with proper layout(like in jointjs; DirectedGraph Layout). Now, this auto layout is not supported by Raphael so, i have to use an external library only for layout purpose.
Now, as far as i've worked with JointJs, it does a acceptable job but even though lets say i've graph from raphael, still not sure how will i use it with DirectedGraph Layout.
D3 was also an option but after i explored it, i could not get much about layouting. Not necessarily i should use JointJs but could be another library which can support my use case.
My main concerns are:
How to draw undirected graph in Rapahel.
How to consume the graph drawn in Raphael in JointJs (or any layouting library)
OR
Layout technique/library that would do both diagramming and layout like in image from link below.
http://s000.tinyupload.com/?file_id=10320373554237333472
Any resources/code snippet will be helpful. Thanks in advance!

Drawing icons in the middle of polygons - earth plugin

I was wondering if there is a good way to draw icons (markers) in the middle of polygons, using kml in google earth plugin.
Currently I solve this by calculating the middle, and for every polygon adding a placemark with the icon in the calculated center.
But then i have to make sure that when I remove the polygom I remove the marker also.
Is there a way to make them connected and not seperate like that?
Thank you!
You could encapsulate the placemark and polygon objects into a single object, allowing you to create custom "PlacemarkPolygons" passing in any options you require. So you would have.
function PlacemarkPolygons(options) {
// your set up...
}
To see what I mean take a look at this "CustomOverlay" example that wraps a groundOverlay and a polygon to provide click events for the groundOverlay.
http://jsfiddle.net/2bUXQ/
Although the Google Earth API objects are different from yours, the principal would be exactly the same. You would define a custom object that wraps the two API objects that you want to associate together, along with any methods that help you to use it.

AVVideocomposition AVPlayerItem position of video-layer

I used Apple's AVEdit-Demo, tweaked it a little and was able to add CALayers with animations and images to the video-composition. So far, this works fine.
It uses AVVideoComposition and AVPlayer/AVPlayerItem to merge videos (and show them - the export rendering is a little different).
I added a layer with a png with some transparent areas, sort of like a mask, that hides parts of the video. Now I need to move the video-layer, so I can adjust the hidden parts (a.k.a. the visible part). The Mask covers the whole screen (in a CALayer), so moving the Mask-Layer isn't an option.
I didn't find any properties or methods, to adjust the position of the video-layer...
Any Ideas?
Found it...
I had to access the AVMutableCompositionTrack in the AVMutableVideoComposition and set the preferredTransform there (CGAffineTransformTranslate).
However - the Docs state, that this should be possible in a AVMutableComposition as well (AVAssetTrack setPreferredTransform).
I couldn't get this to work, though.

Resources