I have an Overlay KML Polygon exported from a Shapefile, is there any way I can find weather a point is in that polygon(KML) or not?
I know this is possible when we create polygon trough Google map api like
var polygon = new google.maps.Polygon([], "#000000", 1, 1, "#336699", 0.3);
But how we can do this with KML overlays?
You have 2 options with KML:
use a third party parser like geoxml3 or geoxml-v3 to render your KML as native Google Maps API v3 polygons, then use the way you know how. example using geoxml3
import your KML into a FusionTable, and use the ST_INTERSECTS to check for the intersection of your Polygon with a small circle around your point example using FusionTables. Note with FusionTables you can directly import shapefiles using shpescape.com
Related
I'm building a web application using Angular and mapbox-gl-js as map library.
The map tiles are projected using EPSG:4326 Plate-Carrée and the dataset is GeoJson (WGS84).
Since mapbox supports only web mercator projection, the data is not displayed in the correct position on map.
Any suggestions how to reproject the dataset so mapbox is able to display the data in the correct location?
Thanks.
If I understand your question correctly, you have some raster tiles which are "projected" (well, not really) in EPSG:4326, and you would like to display them in Mapbox-GL-JS. You also have another dataset, in GeoJSON, also provided in EPSG:4326, which you would like to overlay.
As you note, Mapbox-GL-JS only supports the EPSG:3857 (Web Mercator) projection. It projects datasets (but not raster tiles) from EPSG:4326 to EPSG:3857 in order to display them.
Your good options are:
Find a different basemap in Web Mercator
Find a web service which can reproject the tiles you have on the fly
Maybe there's some way where you could let Mapbox-GL-JS think it's displaying your tiles in EPSG:3857, then somehow adjust the coordinates of your overlaid dataset so that when they're reprojected from EPSG:4326 to EPSG:3857 they end up in the right positions. But I can't think how to achieve that.
You could try asking at gis.stackexchange.com.
I use EPSG:3857 projection for View in Map. I can easily add OSM to my map.
When I use EPSG:3395 projection for View, I can easily add tile-layer with source in EPSG:3395(world mercator) projection.
But how to combaine on map tile-layers with different source projection(3857 and 3395) ? Is it possible in openlayers-3 ?
Thanx!
Not yet possible, should be possible around october when raster reprojection work has been finished.
https://github.com/openlayers/ol3/issues/3785
I have a simple Google Map. I've added a marker at a given lat, lng.
I want to use turf.js to calculate a 1km buffer which I can then display as a Google Maps polygon.
The path that turf.buffer() returns is an ellipse. The distance from the marker to the boundary is correct latitudinally. However it is short of 1km longitudinally. It looks like there is a problem with the projection, however both the Google Maps API and turf.js documents state WGS84 is the default projection.
The end game is using turf.js to buffer Points, Polylines and Polygons so I can't just draw a Google Maps circle as a workaround unfortunately. I would consider migrating to Leaflet, however we are already quite invested in developing for the Google Maps API
I've created an htm file here showing the problem
I'm not going nuts. The buffer isnt geodesic so at the equator you get a round buffer and as you move north or south your buffer becomes squashed longitudinally towards the poles. The turf.js team are aware. See https://github.com/Turfjs/turf/issues/110 for full details.
I'm looking at using clipper.js instead. This is a cartesian library (2d) so in the uk i can use osgb eastings and northings. I will also have to flip north and south as clipper assumes we are dealing with standard graphics i.e. The y axis is inverted like in css with 0,0 being the top left.
Im going to use geotools to transform between osgb and wgs.
I have a Google map (API 3) with fusion table polygons (showing only 1 polygon at the time using object FusionTablesLayer).
For the view-port, i am retrieving some specific data from a "WFS" which result in multiple polygon coordinates.
i would like to determine whether each of the WFS polygons fall (partially) within the plotted fusion tables polygon. I yes, it should count the WFS polygons which are within the fusion tables polygon.
How do i approach/achieve this?
I found the solution myself. The maps api v3 has the solution already.
From the fusion tables, I created a google.maps.Polygon using gviz and geoxml3.
Then I looped each WFS polygon, and looped those coordinates through the method google.maps.geometry.poly.containsLocation()
I would like to find out what projection is google map using is it EPSG:4326 or P900913 ? Also if you use the drawing tools what projection coordinates are generated?
EPSG3857 is the official designation.
Interactive web maps are using "Spherical Mercator" system which uses Mercator projection on
the sphere instead of WGS84 ellipsoid.
More information
Google Maps uses the Mercator projection for this purpose
https://developers.google.com/maps/documentation/javascript/maptypes#WorldCoordinates