Highmaps get lat/lon from a hc-key - highcharts

Working with highmaps from Highcharts. I'm displaying a world map and trying to display some states like capitals using mappoint serie.
To display the states I need the lat/lon or the x/y coordinates. Is there any way to get the position based on the hc-key or the name of the state ?

Related

How do I convert pixels into x coordinates of the data in ios charts

How can I convert pixels into coordinates? I want convert the translation from the viewPortHandler into the coordinate system of the data. I'm using https://github.com/danielgindi/Charts
Not sure I got your question correct because there's not too much details in it. If you have coordinates of some point on chart view in view coordinate system (say viewPoint) and want to get coordinates of that point in internal coordinate system of chart, you can get those coordinates using valueForTouchPoint(point:axis:) method like this:
// assuming that your data is related to left yAxis
chartView.valueForTouchPoint(point: viewPoint, axis: .left)

How to get the hc-transform for a custom map?

I have a GeoJson from brazil which is a more detailed version of the official HighMaps Brazil map. In this JSON I have the states divided into its mesoregions.
When I tried to draw a point on top of this GeoJson I got the message telling me that this functionality was only supported with official highmaps maps. Reading the documentation I found out that I should create an object hc-transform on my geojson. I thought it would make sense to use the same hc-transform used by the official HighMaps Brazil map, and when I did, it kinda works ok: It gives me the the same point with fromLatLonToPoint() method but then when I use the method toPixels() to get the "canvas" position (and draw something on top of it) it gives me different values.
The code Im using is this (it works fine for brazil official highmaps):
let point = chart.fromLatLonToPoint({lat: n.lat, lon: n.long});
let x = chart.xAxis[0].toPixels(point.x, true);
let y = chart.yAxis[0].toPixels(point.y, true);
// Draw the div / point / whatever on the (x, y) position
The GeoJson I am talking about you can find here: https://github.com/Menighin/HighmapsExperiment/blob/master/geo/mesorregiao.json
Checking Highmaps oficial Brazilian map I can see that each polygon also has some highcharts attributes (hc-middle-x, hc-middle-y, etc). Does that make any difference? If not, what am I doing wrong?
EDIT
Turns out my hc-transform doesn't seem to be right as we can see on this fiddle:
http://jsfiddle.net/0vm8a4x3/
If we uncoment the line 8, we can see that the city Belo Horizonte, is not plotted on the right position on the Mesoregion map.
So, how can I get the hc-transform right?

Here Map : How to differentiate between two markers at same location

How can we differentiate among multiple NMAMapMarker at same location.
As we have marker.userdata property for google markers but how to manage data for markers in Here Maps.
When you are placing multiple markers at the same geo-point, they are stacked on top of the other. Since they are all at the same coordinate, only the top most one will be displayed. To enable multiple marker to be shown at the same coordinate, you will need to have some logic to slightly shift the position of markers. For example check if there is already a marker at the point, if there is an existing one, then use some logic to slightly change the coordinate value of the new marker to be added at the point.

iOS: (Swift) How to show distance from current location and exist annotation on annotation subtitle

I am currently working on map application base on iOS using Swift language. I would like an suggestion because after I plot all the pins on map view
(which I receive data from my server using JSON frameworks call Alamofire)
I would like the subtitle of all annotations on map to show distance from user current location.
Now it can add annotations onto map view but can only show title and subtitle base on information receive from my server.
Thank You.
If you have two CLLocation instances, you can calculate distance with the following code:
var one, two: CLLocation
// assign one and two
let distance = two.distanceFromLocation(one)
CLLocationDistance is just double and distance calculated in meters

mapping latitude and longitude values onto an image

i'm trying to geocode values and map them to a satellite image of a city (new york city to be precise). i've successfully done this before using a geospatial image of the world, and then mapped/scaled longitude and latitude values from the max lat/lng range (-90,90 & -180,180) to the max width and hight of the image (0,width & 0,height) which worked perfectly. i'm a bit confused how to do this to just a map of a city.
currently, i have a hi-res satellite image of new york city, and have positioned it so that it perfectly aligns with the map of new york city on Google Maps (i'm using their API to geocode my locations). i've attempted to get the top/bottom latitude values and left/right longitude values of the satellite image i'm using, and tried to scale any longitude/latitude values that needed to be mapped onto the image within this range. however, this didn't seem to work. is there another method i could use so that it would be possible to dynamically map lat/lng coordinates onto a satellite image of new york city?
this is essentially the image that i would like to map onto:
thanks.
If you know the image size and its geographic extent (lat/lon values), you can use something like:
x = imageWidth * ( pointLon - ImageExtentLeft ) / (ImageExtentRight - ImageExtentLeft);
y = imageHeight * ( 1 - ( pointLat - ImageExtentBottom) / (ImageExtentTop - mImageExtentBottom));
By the way, if you are using the Google Maps API to geocode your locations, why don't you use its functions to add markers directly to your map? (Maybe I didn't completely understand your case)
var latlng = new GLatLng(pointLat, pointLon);
map.addOverlay(new GMarker(latlng));
Hope it helps
You are engaging in a process called image registration or map rectification. There is a whole set of remote sensing dedicated to the equations for doing this.
Perhaps you can just start with this web site - it should basically do what you need
http://labs.metacarta.com/rectifier/ (dead link)
if not then maybe look at tools like QGIS or GRASS. If you have money and time you can also use ESRI ArcGIS desktop or ERDAS Imagine or IDRISI.

Resources