Polymaps - Polygon with label inside from geoJSON - gis

I have a map using Polymaps (http://polymaps.org/) and am able to draw polygons based on a geoJSON file. How can I add the name to the polygon.
For example: Here is a bit of my geoJSON
"properties": {
"name": "NH",
I want to draw the polygon with the text NH inside of it.

Looking at the current version code, that feature is not implemented on polymaps. You may want to fork polymaps so you can have <text> items near each graphic item.

Related

Map Data in JSON format. Easily edit a selection of vertices

I have the Spanish provinces polygons in a JSON file. For one province, the schema looks like this:
{
"geometry":
{
"type": "MultiPolygon",
"coordinates":
[[[
[-7702,-4944],
[-7678,-4979],
[...,...],
[-5967,-4077],
[-5982,-4097]
]]]
},
"type": "Feature",
"properties":
{
"labelrank": 20,
"code_hasc": "ES.CN",
...
"type": "Comunidad Autónoma",
"id": "ES.CN"
}
}
I would like to move the vertices of some provinces as described in the image below. The reason for that is that the visualization looks terrible if I project as it is defined in the JSON (half of the map is just empty space).
Using mapshaper.org I was able to identify the coordinates where I should send the most northern vertex. From here it just a matter of addition to each vertex in all polygons. Before I create a script in Python to do that, I would like to ask the community if there is a software or tool that allows me to select all desired vertices and move them to the desired position, something like moving a selection of nodes using Adobe Illustrator or AutoCad.
Ian Turton kindly recommended using QGis for that purpose. The use of the tool is quite straightforward for doing this kind of batch polygon displacements:
Open the json file with your geodata
In the Attributes toolbar,
click on "Select features"
Select the features that you want to move:
In the Vector Toolbar, click on "Toogle editing"
Eventually you may need to display the Advanced Digitizing Toolbar. Right click on any toolbar and select "Advanced Digitizing Toolbar" under Toolbars
With your feature still selected, click on the "Move Feature" icon
Click on your selected features and move to your desired location
Because I just wanted the new polygon coordinates for the Canary Islands, I exported the features as GeoJson and replaced accordingly.

Custom (text) overlay on google map via KML

Is it possible to draw a custom text overlay on a google map via a kml file. I'm drawing several polygons (e.g. linear ring) that separate a region into districts and I want to indicate what district the polygon is and without an marker pin.
KML does not have a native way to draw text or fonts directly on the map.
Your options include:
Add a Point/Placemark with a Label at the center of your polygon. In the IconStyle, set scale to zero, so that you only see the label.
Use a GroundOverlay image that contains the text and has a transparent background
Find a way to generate KML lines or polygons in the shape of your letters/text, and place those on the map.

Change Google Maps direction line to icons

Is there a way to change the default Google Maps direction line, the blue line that you are meant to follow, into a series of icons?
So instead of having a blue line showing the route on the map, I'd like to replace this with a series of small icons.
Or, if that isn't possible, can I place icons along the route in say 1km increments?
I see plenty of examples of replacing the start and end markers but not of the line.
Yes, it is possible. One option:
PolylineOptions to the DirectionsRenderer, you can also apply symbols to the Polyline
(example using a "dash" symbol)
or extract the route data and use it to put icons at all the vertices on the polyline (like the answer to this question, but with a transparent polyline)
example of a custom DirctionsRenderer
markers every 2km on a Polyline
markers at 2 arbitrary distances on a directions polyline

Getting coordinates of polygon areas defined in KML

I have displayed a google map using a KML file as source. The map has a number of polygon areas marked in it. Is there any way to get the center coordinates of each of the polygons without the click event ? I need to display an info window above each polygons when the map is displayed.
Thanks
google.maps.KmlLayer is uses tile based rendering, you can't (at least at present) access the coordinates of the polygons except on a click.
You could use:
FusionTablesLayer, import your KML into that, then query it using either a Fusion Tables API v1.0 or a google.visualization (GViz) query) for the coordinates to get their center.
example using FusionTablesLayer and GViz
A third party KML parser like geoxml3 or geoxml-v3 to render the polygons as native google.maps.Polygon objects, and get their center. This will have performance issues with complex KML.
example using geoxml3

Problem customising KML layer in Google Maps

I have got a file which overlays the state of New South Wales' electoral boundaries onto a Google Map. The markers which popup on each electorate really interfere with the visuals of the map when zoomed out. I have found how to disable the info window, but can't work out how to turn the markers off all together.
Map example is here:
http://www.codepress.com.au/nsw_lower_house_map.html
With markers turned off, is there then a way to make the whole electorate polygon clickable to work with in JS?
To make polygons clickable bind an event listener to a layer after you add layer to the map
ctaLayer.setMap(map);
google.maps.event.addListener(ctaLayer, 'click', function(kmlEvent) {
var text = kmlEvent.featureData.name;
alert(text);
})
The above will alert the name of the feature that you clicked on (providing the name is set in KML). PLEASE NOTE: for polygons to be "usefully" click able they need a fill to be set. Your KML file does not have the fill so the only area click able will be the border of the polygon. You will need to set the fill to make this feature useful.
In general The KML feature object returns the following data:
{
author: {
email: "nobody#google.com",
name: "Mr Nobody",
uri: "http://example.com"
},
description: "description",
id: "id",
infoWindowHtml: "html",
name: "name",
snippet: "snippet"
}
Again - providing these are set in KML
To get rid of the markers you will need to modify the KML and remove all Placemarks and their containing Folder which have no polygons specified in them - only Point data (which is rendered as a marker). Make sure you re-validate your XML after deletion.
Here is your file without the markers http://www.mediafire.com/?f9ewd0c5ymk3ccv . However you will need to make sure that your polys have fill set otherwise you will only be able to click on the borders.