score:1
Ok, so this is an akward solution : I still don't understand how this could solve the problem, but it works... [EDIT : this is indeed the correct solution for the time beeing, see EDIT at the end of the post]
What I did was :
use the proj4 string for ESPG2154 as previously said : "+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
set the mapData with xy coordinates in EPSG2154's system : [761574.9000000217, 6918670.299997976], [761648.2000000217, 6918469.799997974], ...
set the hc-transform/crs on the mapData as previously said : 'hc-transform': {'default': {'crs': '+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs'}}, 'crs': '+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs'
set the mappoint datas using x/y instead of lat/lon, without any 'hc-transform' or crs, but with y coordinates inverted : data: [{'x': 727759.0000000142, 'y': -6884382.999997055, 'name': 'Chateau-Thierry'}, ...]
Note that :
- I inverted the y coordinates, for the mappoint datas, and that these are not the correct coordinates in any sense ;
- I also set yAxis to reversed: true, which should not be the default value as stated in the API's doc. But in fact it doesn't change anything if you remove this line or not : somehow, using multiple series including one mapData seems to be changing the default property (at least when using proj4 in this configuration). In fact, if you put it to reversed:false, you won't have any correct results, even if you don't invert the y coordinate as stated before.
I think this is some kind of undocumented bug (I might be wrong still), I will try to refer if to highcharts'staff...
See complete functional exemple in this fiddle.
<html>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.6/proj4.js"></script>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.highcharts.com/maps/highmaps.js"></script>
<script src="https://code.highcharts.com/maps/modules/data.js"></script>
<script src="https://code.highcharts.com/maps/modules/exporting.js"></script>
<script src="https://code.highcharts.com/maps/modules/offline-exporting.js"></script>
<div id="container"></div>
<script type="text/javascript">
Highcharts.mapChart("container", {
title: {
text: 'Testmap Highmaps Hauts-de-France'
},
mapNavigation: {
enabled: true,
buttonOptions: {
verticalAlign: 'bottom'
}
},
yAxis: {
reversed: true
},
series: [
{
name: 'areas',
type: 'map',
mapData: {'type': 'FeatureCollection', 'features': [{'id': '1', 'type': 'Feature', 'properties': {'DEP': '02'}, 'geometry': {'type': 'Polygon', 'coordinates': [[[761574.9000000217, 6918670.299997976], [761648.2000000217, 6918469.799997974], ..., [699287.6999999998, 6901218.199997955]]]}}], 'hc-transform': {'default': {'crs': '+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs'}}, 'crs': '+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs'},
},
{
name: 'cities',
type: 'mappoint',
data: [{'x': 727759.0000000142, 'y': -6884382.999997055, 'name': 'Chateau-Thierry'}, ...],
color: 'black',
marker: {
radius: 2
},
dataLabels: {
align: 'left',
verticalAlign: 'middle'
},
animation: false,
tooltip: {
pointFormat: '{point.name}'
}
},
]
});
</script>
</body>
</html>
EDIT
So this is indeed a tricky problem... I have been in touch with highsoft and there seem to be multiple facts to take in consideration : - first, the yAxis.reverse=true IS the default behaviour, regardless to what is currently stated in the doc ; - secondly, some inner algorithm about mapData corrects this behaviour, because this type of layer is assumed to be GeoJSON ; - 3rdly, this is not the case for mappoint aw well as mapbubble layers.
Notice that if you set yAxis.reverse = false, you are up for some bad time. The mappoint layers may seem to be correctly superposed with your mapData (if I understood this correctly, this have something to do with the mappoint layer's y range to be more or less alike to those of the map area.
Highsoft has opened an issue on this subject.
Morality : my solution was in fact the good one (at least until they decide what to do with this "issue"). As for this version of Highmaps, always work with yAxis.reverse = true, and be aware that mapDatas passed as GeoJSON are not affected by this command.
Source: stackoverflow.com
Related Query
- Manage projections in custom Highmaps
- Highmaps : Custom data label on world map
- Highmaps - Creating custom buttons using Exporting
- How to add data to a custom HighChart's HighMaps map? joinBy?
- Custom Cursor in Highmaps when no data is available for hovered country
- Strange character in the Highstock source code
- Creating a bubble map from custom GeoJson with Highcharts / Highmaps
- Create custom Map for Highmaps using Shapefiles and QGIS
- Highcharts Highmaps How to add mappoint to custom map
- How to use a custom JSON map in Highmaps
- How to implement mapbubble in highmaps using custom maps json generated using qgis?
- Color coutries/continents with own custom colors in highmaps
- Custom map with Highmaps adding mappoint series in latitude and longitude using proj4js
- Getting Custom GeoJSON File To Work In HighMaps
- Trouble finding the correct crs value for bubble map on custom highmaps GeoJSON file
- Custom HTML marker in Highmaps
- Manage multiple highchart charts in a single webpage
- Drilldown in highmaps - how to remove a series
- highcharts datetime x-axis custom formatting
- Adding thousands separator for custom formatted highcharts tooltip
- drawing custom lines on highchart graph
- Highcharts: Add a custom image button
- Highcharts - How to set custom colors for the series
- How to apply custom color on candlesticks based on OPEN/CLOSE values?
- Tooltip on custom button in Highcharts
- Highmap R (or) javascript - adding custom legend
- Optimize JavaScript DrillDown code
- How to align centre a custom label in highcharts
- Custom Highcharts Context Menu Button Appearing in Every Chart on Page
- Highcarts custom legend
More Query from same tag
- Styling the stacked column highchart datalabels individually
- R Shiny Highcharter - Add series without full reload
- Can I set a minimum positive and a minimum negative axis value in Highcharts
- Highcharts yaxis higher values displayed lower
- DotNetHighcharts - How to only use first column of 2d array as Data
- Highcharts Dynamic Chart with MySQL Data doesn't reload
- JSON Result for Highcharts Data Object in C#
- How to hide labels in the highcharts in the pie
- High Charts how to show multiple columns value on label
- Reversing the min and max values in column chart
- How to attach click event function in Highcharts
- Customize legend pie highchart into tag div
- Highcharts - Enable border for 1 column/bar only?
- Preventing event from executing consecutive times React
- highcharter convert value to percent in tooltip
- How to show categorized Highcharts Chart using csv file
- Overwrite Highcharts X Axis
- Hiding items in highchart legend
- How can we plot Highcarts organization chart in R language?
- Highcharts Spline not drawing graph lines for first 30 points.
- Multiple highchart with similar structure in R
- Highcharts - Even tick with uneven spacing
- Highcharts errorbar with corsshairs
- How to hide empty column in column hightcharts with multiple series
- HighChart Line Draw issues(How to draw contineous line between 2 points )
- Is there any method to select only one series marker state in highcharts?
- HighCharts: Is it possible to remove every other value on the x-axis?
- How to remove the decimal .00 from the default highcharts configuration?
- Highchart Activity Gauge always display text in the center
- Rebuild Highchart doesn't work