Use Google My Maps Polygons in my API - javascript

Here is what I would like to achieve :
I have a Google My Maps map, with a few polygons over a city, representing districts.
On the server side of my application, I would like to create a tool that, when given a position, can return me the polygon it is into.
Is it even possible ?
Maybe My Maps is not the good service, if so, I am totally open to work with something else.

One option is to use the geoxml3 kmz branch with a binary proxy to access the .kmz data from Google MyMaps, that will render your data as native Google Maps Javascript API objects. Then you can use point in polygon tests to determine which polygon your input point is in.
Point in polygon example (using another third party library, a version of epoly, ported to the Google Maps Javascript API v3).
Example rendering MyMaps output using the kmz branch of geoxml3
(Note: I couldn't make your data work, there were character encoding issues that made the KML invalid).

Related

GPS Data with HTML

I'm working in a project where I have to collect data from a GPS Module (NMEA data) and pass it to an html application so I can display exact location of the device on a Google map. I have created the map using the google maps api but I'm unsure of how to pass the NMEA data through my application. What would be the most efficient way to do this? Thank you.
If you use Google's My Maps (this is a very easy method to get your own map in your own HTML page) you can import GPX data straight into the map. You just need to convert your NMEA data to GPX.
If you're comfortable with the command line GPSBabel looks relatively simple to use (there are a couple of GUIs available if needed). Alternatively, OpenStreetMap has some other alternative methods that you can try.

Google Maps API Postal Code Boundaries

I've found an answer using Google Maps Marker but since its dead, I hit a dead end.
I was wondering if anyone would have any knowledge on how I would replicate this for a user on my website: https://www.google.ca/maps/place/Toronto,+ON+M4N+3M5/#43.7216028,-79.3771275,16z/data=!3m1!4b1!4m5!3m4!1s0x89d4cd2e4f1652cd:0xee93f0117ea5797d!8m2!3d43.7215696!4d-79.3768256
I would like to take the users postal code and outline there boundaries. I'm not sure if this a broad question but I need to stick with using Google Maps API in this case.
Currently Google Maps JavaScript API doesn't expose any boundaries of geographic features. There is very old feature request in the public issue tracker to add this functionality, however it looks like Google didn't set high priority on this task:
https://issuetracker.google.com/issues/35816953
Feel free to star the public feature request to express your interest and subscribe to further updates from Google.
You can get polygons from other sources and add them to Google maps as additional layers.
The nice workaround to get polygons in GeoJSON format from OpenStreetMap is described in the following answer:
https://stackoverflow.com/a/40172098/5140781
So, if you download the GeoJSON you will be able to add it to map using the data layer and its loadGeoJson() method:
https://developers.google.com/maps/documentation/javascript/datalayer#load_geojson
You can style colors of GeoJSON objects and create info windows. Just read the aforementioned documentation.
I hope this helps!
You can't get the boundaries directly from Google Maps API. Best option would be to have geojson files for each postal code and then load the relevant one as a geojson layer in Google Maps.
https://developers.google.com/maps/documentation/javascript/datalayer#load_geojson
The solution I ended up using was googles geo coding api: https://developers.google.com/maps/documentation/geocoding/intro
It gives the boundaries you need for a neighbourhood which then can be used against the google maps api to plot the area.

Mapbox load surrounding tiles

Is it possible to specify in Javascript to load surrounding tiles using Mapbox like google maps does? If so, how?
It looks rather glitchy every time you pan the map it only then starts loading the necessary tiles.
I cannot show you my app, but if you look at this Mapbox map example the same problem can be found here: https://a.tiles.mapbox.com/v3/ilyakar.i68649in/page.html?secure=1#14/50.0875/14.4152.
Foursquare uses Mapbox as well, somehow they eliminated this problem..
You are using v3 of the api - have you tried to upgrade to v4 of the api?
"Check your code to see if you’re requesting v3. If you’re still using v3, you’ll need to update to v4. In addition to changing the version number, you’ll also need to pass one of your access tokens with the request."
Re: https://www.mapbox.com/help/blank-tiles/

Google Maps WebService API - show directions result on map

EDIT:
How is it possible to get a DirectionsResult json object from Google maps Web Service APIv3 without breaking the "laws" of xss?
if so, how is it possible to parse that result and show it on a map (in the js API I use DirectionsRenderer) ?
I can do the above with the js API, but am failing miserably with the Web Service. also, use of JQuery / JQM is available.
Any ideas?
Sounds like you don't actually want to execute Javascript, you just want to parse JSON. There are many libraries available to do this.
I recommend you to use Javascript OpenLayers Library displaying map data including Google Maps in most modern web browsers, with no server-side dependencies and Vaadin's OpenLayers Wrapper which contains server side wrapper component for OpenLayers Maps.
Check out some of the applications that were built using these tools:
http://trac.osgeo.org/openlayers/wiki/Gallery

Is it possible to make a custom map in Google Maps API v3?

I'm working on a personal project involving map-making tools for a tabletop game that I play. I've worked with Google Maps in the past before, and it looks like in version 3 of the API, they have removed the API key restriction.
I have done some research into making a custom map, and have come across this page on mapki, but the example seems to be focussed on creating new tiles for existing real-world coordinates.
Is it possible to make custom maps that are not dependent on real-world coordinates in the Google Maps API v3?
(Slight tangent: If it is not possible to do this, what other tools exist to make custom maps?)
You could look at OpenLayers. I get the impression it's used a lot in the OpenStreetMaps community.
OpenLayers makes it easy to put a
dynamic map in any web page. It can
display map tiles and markers loaded
from any source. OpenLayers has been
developed to further the use of
geographic information of all kinds.
OpenLayers is completely free, Open
Source JavaScript, released under the
2-clause BSD License (also known as
the FreeBSD).
You could use Mapnik to render the tiles and serve them yourself. The OSM wiki has lots of documentation on doing that sort of thing.

Categories

Resources