I'm having a lot of trouble integrating the Google Maps API into Node.js. I'm currently using the node-googlemaps library.
However, I can't seem to be able to use the Google Maps geometry library specifically within this API.
So far I've gotten the directions API working. I would like to construct a polyline from the result of directions response, and then see if the polyline contains coordinates.
I guess the geometry API isn't 100% necessary, but it's something that I know would work if I could just get it working through Node.
Thank you!
The spherical-geometry-js library ports the Google Maps geometry API, so you could use it alongside node-googlemaps in your code. (Disclaimer: I'm the author of spherical-geometry-js.)
Related
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.
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).
I'm trying to implement "Measure Distance" in google maps v3, something like what we can do in Google Maps Web.
I wonder if there is a library that implmente this as a drawingMode of DrawingManager.
You can now use this MeasureTool library for Google Maps JavaScript API v3 to do similar to what Google Maps offers.
Measurement tool for Google Maps API - project page
Here is a live demo.
Here's an example I found of a simple ruler that measures distance between two markers:
http://www.barattalo.it/measure-distance-google-maps
The source code is available via a link on that page.
I hope to use the same basic idea in my own Topographic Maps to drag out a series of markers, then use the resulting PolyLine to draw an elevation profile, etc. I'll post a reference to my code here if I'm successful.
That said, since this "Measure distance" UI has been part of the standard desktop Google Maps since July 2014, I would hope that the Google team might share it via the published Google Maps API soon, simplifying our work (not to mention standardizing the UI for such user drawn paths).
FYI,
Chris
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.
On maps.google.com you can see a brilliant example on how a google maps application can suddenly turn into a google earth application smoothly.
I'm developing a google maps application, working with API version 3. I read the following line in the Google Earth API summary
If you have an existing Maps API site,
you can 3D-enable your page with as
little as one line of code.
But I have searched for hours without finding any clue how to enable 3D in my application. I've built my application on the google.maps.Map constructor and included the google mas API from this url: http://maps.google.com/maps/api/js
Does anyone know what I'm talking about and/or know how to enable 3D in a google maps application in 1 line?
Codemonkey
The previous answer by Fraser is perfect for V2 of the Maps API. However it's strongly recommended to use V3 since V2 has been deprecated.
To get similar functionality in V3 you can use the utility library at http://google-maps-utility-library-v3.googlecode.com/svn/trunk/googleearth/ -- simply include the javascript library, and then in your code instantiate the Earth layer for your map:
var googleEarth = new GoogleEarth(map);
To add the Google Earth instance to your map, simply add the G_SATELLITE_3D_MAP to your map with GMap2.addMapType().
var map = new GMap2(document.getElementById("map_canvas"),{ size: new GSize(640,480) } );
map.setCenter(new GLatLng(42.366662,-71.106262), 11);
// Enable the Earth map type
map.addMapType(G_SATELLITE_3D_MAP);
var mapControl = new GMapTypeControl();
map.addControl(mapControl);
map.setMapType(G_SATELLITE_3D_MAP);
Here is the information on Integrating v2 of the maps Api with the Google Earth Plugin
http://code.google.com/apis/maps/documentation/javascript/v2/services.html#Earth
Maybe Google means using KML(KMZ) files?
This language supports by Googgle Earth and Google Map.
I can make mistake, but it link is helpful - http://sketchup.wikia.com/wiki/KML