Drawing HERE Data on to ESRI JS Map - here-api

I am currently investigating the possibility of utilising the HERE APIs as source data inputs into possible solutions we would like to develop as a company on ESRI.
I understand that any data we retrieve from the API, i would need to create ESRI objects on the fly, and add them to an ESRI map layer.
However, one thing that is not clear in my mind, is how to calculate the tiles for my particular map extent.
The REST API specifies some base information, regarding calculating tiles based on lat lon - but what is the lat/lon of? is the map center? is it the bottom left or bottom right?
Are there any JS helper methods that HERE have, that would calculate the tiles required for a particular extent?

Are you referring to this documentation part: https://developer.here.com/documentation/map-tile/common/map_tile/topics/mercator-projection.html ?
It is the coordinate of the part of the map which you want to display e.g. the center of your map view.

Related

Acquire and reconstruct map from online interactive maps

I am scraping data from some interactive maps, including markers locations, and would like to acquire and reconstruct the map image to use with those markers. For example, consider the map for the videogame Elden Ring provided by Map Genie here.
From what I understand, the tiles are 256x256 and are fetched depending on the user's view position and their zoom.
I am unaware how I may programmatically acquire all the map tiles (and put them together) such that it still relates to the longitude/latitude data of the scraped markers. I generally use Selenium in python to scrape web data, but in this instance, the data is 'dynamically fetched', and I'm not sure how to start.

Does a polygon loaded from a KML contain a given Lat/Lng in Google Maps API

I have a KML file which contains a polygon. I am wanting to write a simple application which will give a true/false result on whether a lat/lng is inside of that polygon.
For whatever reason, this seems to be more difficult that it sounds, as the google.maps.KmlLayer seems to be very limited with the functions it offers.
I am aware that a non-KML map has a "containsLocation()" function which does exactly what I need, however, the KML layer contains no such function
I am not quite sure how you are using the KML file however I would suggest the following approach:
Parse your KML file (Many libraries available for many languages)
Use the parsed KML data to render your Polygon using the Google Maps API (i.e. reconstruct you KML polygon in Google Maps with the Google Maps methods)
Use the Google Maps API containslocation() method to check whether a co-ordinate is inside the Polygon
The Google Maps API has a large feature set so by doing this you could incorporate some of their methods, i.e. You click on the map and the program tells you wether the point you have just clicked is inside the polygon or not. Have a look at this, I suspect this is what you want to accomplish (or at least similar to it).
Edit: By parse I mean decode the KML

what is the MapBox solution to add a vector-tile layer into Leaflet map?

Background:
Leaflet map
a vector tile layer
MapBox Studio to generate vector tiles (protocol buffer format)
MapBox.com for tile hosting
using Leaflet.MapboxVectorTile plugin to parse and render MapBox vector tiles
Issues:
Cannot get original feature geometry: I wanted to fetch feature geometry so can zoom to it e.g. when user clicks at it. But this plugin (Leaflet.MapboxVectorTile) doesn't have a clear way to do so. The geom values (including BBOX) are all in relative coordinates (i.e., not the original geometry)
Poor capability in identifying feature (click/hover): Another problem with this plugin is its identification algorithm is not robust enough. The authors disabled hover-identify as it turns out to be very slow. For clicking, I noticed sometimes it's hard to select a polygon (happens for some polygons and depends on where you clicked within the polygon), you have to click at certain locations so the plugin is able to identify the feature.
This plugin is very good in my experience except for above two issues.
My Questions:
Is there a counterpart MapBox solution that does the similar thing to this plugin? In other words, to parse and render a vector tile layer service on map, with support in robust feature identifying and ability to fetch feature geometry?
Currently the tiles generated in MapBox studio is in .pbf which is great in terms of efficient data transmission. I wonder if it supports JSON format (GeoJSON or TopoJSON) out of box? If it does, I probably could try using MapBox.JS featureLayer to consume vector tile json data.
I understand MapBOX GL.js is designed for vector tile based maps. I am looking for adding a vector tile layer though.
appreciate any response. thanks!
You'll want to try out mapbox-gl-leaflet, a library that integrates the efficient Mapbox GL library into Leaflet as a layer.
Cannot get original feature geometry
Vector tiles do not contain the original feature geometry. Mapbox GL does provide an api that delivers GeoJSON, but it isn't going to be your raw data: if it was, then the map would be slow and inefficient, since raw data is over-detailed.

Google Maps - How do I efficiently create a polygon with many points?

I need a polygon for every German state. I go all the GeoPoints in one JavaScript-file but the file is because of the amout of points about 4MB. I've been googling and thinking about this problem all day but couldn't figure out a solution...
How can I use Google Maps polygons without forcing the user to download a huge js-file with the coordinates?
Thanks!
Ron
You can encode the polygon points to vastly reduce the size of the javascript file. To do this, you must include the geometry library.
https://developers.google.com/maps/documentation/javascript/reference#encoding
https://developers.google.com/maps/documentation/javascript/geometry#Encoding
One option is to use a FusionTablesLayer to display the polygons. They are available in the Natural Earth data set that is publicly available.
Example
You could do the same with your points and a KmlLayer if you convert your data to KML.
Well... somehow the points have to get to the user. You could think of the following solutions to reduce the data usage:
Use different polygons for different zoom levels. For example zoomed out you won't need the full details.
only send parts of your polygon back to the user. You can for example send the viewport coordinates to an AJAX script. This one queries your database and/or shapefile and only returns the polygon parts that are visible in the user's viewport
preprocess tiles. If you can generate images from your shape, you can overlay these on Google Maps.

Highlighting borders of state and cities of US in Google Map API 3

I have a scenario where I have to highlight borders and shade a state or city after geocoding it (when I got the lang and lat).
How can I do this, do I need to have a complete information of a city to surround it with polylines? Or is there a way that map API can do this for me.
True. Google does not provide this feature. So what we can do... we can have the lat/long of the borders of the state. And we have to draw polygons ourselves.
I used this JS object. And changed it to Google map object (google.maps.LatLng).
For example:
var statesobj = {"AK": [new google.maps.LatLng(70.0187, -141.0205),
new google.maps.LatLng(70.1292, -141.7291),
new google.maps.LatLng(70.4515, -144.8163)]}
So, it's easy now. Loop on these lat/longs. And you can draw the polygons on every state of US.
So this is the solution I came up. If you guys know some better idea to do it. Please share.
You can also try Google Geo Charts:
http://code.google.com/apis/chart/interactive/docs/gallery/geochart.html
Google Maps API doesn't allow you to retrieve city borders. There are a couple other places from which you can get the coordinates, though:
Flickr API
There is a Flickr API based on photos that people tag, but it's only as accurate as the people who tag photos: so it's good enough for bootstrapping but probably not for production: http://karya-blog.blogspot.com/2012/12/fetching-city-polygons-with-flickr-api.html
Natural Earth Data
An accurate alternative is www.naturalearthdata.com. To get that data from there you just need to make two requests: one with the city name and one with their ID to get the parameters:
unlock.edina.ac.uk/ws/search?name=berlin&gazetteer=naturalearth&format=json
and then
unlock.edina.ac.uk/ws/footprintLookup?format=json&identifier=14126951
and you're set :)
Mapzen
If it's possible for you to pre-fetch the data, go for Mapzen, they have a full and pretty accurate database: https://mapzen.com/data/borders/
I'm afraid google maps API doesn't provide any means to access region (country, state, city, ...) shapes.
If you want to highlight regions you have to create custom overlays based on data acquired elsewhere.
Now the basic map example includes a "mashup" of data. When identifying data is fed to the web service, the resulting output can pinpoint locations on the map.
It shows how a geographic Map Marker is placed on the map to identify a specific location. Map Markers can use the default icon (shown) or a custom image, gauge, or even a chart. Optionally, the map can be configured to display a Map Marker Info window, containing additional location-specific data, when the marker is clicked.
It includes data-driven, colored regions (in this case, representing postal codes) overlaid a map of eg Washington, DC. Logi Info can work with GIS boundary data to produce region overlays for states, counties, cities, school districts, and other areas. Like the Map Marker, regions can be clicked to display a pop-up information window with detail data.

Resources