Do i need use google maps api only to embed litle map with route calculator/display for only one destination? - html

Well i want to upgrade contact page with dynamic map showing location and give oportunity to calculate route for comapny headquatters. Id it necessery for such simple task use Google api? i mean here generating akey etc? Fo i have any other alternatives to google maps?

There's really no reason to mess with the API at all unless you need to customize the appearance or behavior of gmaps. Why not just use an iframe with a url of:
http://maps.google.com/?q=[you-url-encoded-address-here]
or better yet, set up a textbox and a 'get directions' button to redirect that frame to:
http://maps.google.com/maps?saddr=[their-address]&daddr=[your-address]
edit: this works well in modal dialog if you don't want the google logo sticking out like a sore thumb in your pageflow

You could probably embed directly with a specific URL that will configure it to have the destination you want.
By the way, well written answers are much more likely to receive useful responses here.

You could consider http://www.openlayers.org/ as an alternative to google maps.
In fact open layers can be used to add a Google map, or an OpenStreetMap map or a Bing map, etc.

Related

Add custom label to a google maps URL with GPS point

There are numerous SO questions on how to build a URL with a custom GPS location in a google maps URL.
But I can't find something where I can add a custom label to my point.
E.g. I can show a marker by building a URL like this:
http://maps.google.com/maps?q=24.197611,120.780512
But it's just an unnamed point. Can I add a custom label? Like "MyHouse"?
I actually want to add multiple points each with it's own label.
Something like:
http://maps.google.com/maps/dir/24.197611,120.780512//24.297611,121.780512//24.117611,120.180512
and then call the 3 points: House1, House2 and House3
Although you can pass map parameters thought the URL it appears as though changing the marker icon is not an option.
Google Maps URL Docs
You can change the marker icons with the Maps JS API.
Android Intents support label parameters, but the Maps URL currently does not support them. Check out this Stack Overflow post about it
Hope this helps.
I would suggest filing a Feature Request in our Issue Tracker will be a good idea.
Issue Tracker is a tool used internally at Google to track bugs and feature requests during product development. It is available outside of Google for use by external public and partner users who need to collaborate with Google teams on specific projects. You can learn more here.
Bing map does allow add a pin with label with url parameter:
https://www.bing.com/maps?cp=${mapCenterLat}~${mapCenterLon}&lvl=${zoomLevel}&sp=point.${pinLat}_${pinLon}_${name}_${description}_${linkUrl}_${photoUrl}
The name and the following parameters are optional.
However, allow add label could be a dangerous decision,
frauds may add misleading label to the map or on the wrong position.
Bing map docs

Query existing, public Google Map via the Google Maps API v3

I am trying to embed an existing, public Google Map into a website. Specifically this one:
http://goo.gl/maps/cHf2
Of course I could use the iframe embed to achieve this, but I would like a little more control over the map … I imagined being able to pull all the markers from the map and display them as an index next to the map. Kind of like Google already does, but embedded in my page with my own styles and images.
I have been digging through Google, Stack Overflow and the API instructions and couldn’t find any relevant posts. In the GET string of the map on Google we can see this chunk:
&msid=212828439842926497866.0004bfae4da003d8ffd1f&mid=1341413217
I thought in there might be a maps ID and I could use it to query the content of the map through the API? The intention is using Google Maps as a CMS for less technical minded people and not dealing with geo data in our own CMS.
Any help would be greatly appreciated. Maybe I am just missing the forest for the trees.
You can download the kml that specifies the markers in that page and display that on your API based map. This example defaults to displaying it using geoxml3, but you can hide that and display the KmlLayer version.
You should be able to just point KmlLayer to the link (I downloaded the kml and put it on my server so it would work with geoxml3).
Here is an example (taken directly from the documentation) that does that
here is the original

Use a URL to link to a Google map with a marker on it

I want to link to google maps at a particular location with a marker on a particular point.
It's easy to link to a location:
http://maps.google.com/?ll=XX.XXXX,XX.XXXX
But how do I drop a marker at that point too? preferably with a bit of my own text but that's just a bonus.
2017 - Google has released documentation on this see new accepted answer: https://stackoverflow.com/a/44477650/359135
In May 2017 Google launched the official Google Maps URLs documentation. The Google Maps URLs introduces universal cross-platform syntax that you can use in your applications.
Have a look at the following document:
https://developers.google.com/maps/documentation/urls/guide
You can use URLs in search, directions, map and street view modes.
For example, to show the marker at specified position you can use the following URL:
https://www.google.com/maps/search/?api=1&query=36.26577,-92.54324
For further details please read aforementioned documentation.
You can also file feature requests for this API in Google issue tracker.
This format works, but it doesn't seem to be an official way of doing so
http://maps.google.com/maps?q=loc:36.26577,-92.54324
Also you may want to take a look at this. They have a few answers and seem to indicate that this is the new method:
http://maps.google.com/maps?&z=10&q=36.26577+-92.54324&ll=36.26577+-92.54324
If you want to include a zoom level, you can use this format:
https://www.google.com/maps/place/40.7028722+-73.9868281/#40.7028722,-73.9868281,15z
will redirect to this link (per 2017.09.21)
https://www.google.com/maps/place/40%C2%B042'10.3%22N+73%C2%B059'12.6%22W/#40.7028722,-73.9868281,15z/data=!4m5!3m4!1s0x0:0x0!8m2!3d40.7028722!4d-73.9868281
This URL format worked like a charm:
http://maps.google.com/maps?&z={INSERT_MAP_ZOOM}&mrt={INSERT_TYPE_OF_SEARCH}&t={INSERT_MAP_TYPE}&q={INSERT_MAP_LAT_COORDINATES}+{INSERT_MAP_LONG_COORDINATES}
Example for Mount Everest:
http://maps.google.com/maps?&z=15&mrt=yp&t=k&q=27.9879012+86.9253141
Full reference here:
https://moz.com/ugc/everything-you-never-wanted-to-know-about-google-maps-parameters
-- EDIT --
Apparently the zoom parameter stopped working, here's the updated format.
Format
https://www.google.com/maps/#?api=1&map_action=map&basemap=satellite&center={LAT},{LONG}&zoom={ZOOM}
Example
https://www.google.com/maps/#?api=1&map_action=map&basemap=satellite&center=27.9879012,86.9253141&zoom=14
If working with Basic4Android and looking for an easy fix to the problem, try this it works both Google maps and Openstreet even though OSM creates a bit of a messy result and thanx to [yndolok] for the google marker
GooglemLoc="https://www.google.com/maps/place/"&[Latitude]&"+"&[Longitude]&"/#"&[Latitude]&","&[Longitude]&",15z"
GooglemRute="https://www.google.co.ls/maps/dir/"&[FrmLatt]&","&[FrmLong]&"/"&[ToLatt]&","&[FrmLong]&"/#"&[ScreenX]&","&[ScreenY]&",14z/data=!3m1!4b1!4m2!4m1!3e0?hl=en" 'route ?hl=en
OpenStreetLoc="https://www.openstreetmap.org/#map=16/"&[Latitude]&"/"&[Longitude]&"&layers=N"
OpenStreetRute="https://www.openstreetmap.org/directions?engine=osrm_car&route="&[FrmLatt]&"%2C"&[FrmLong]&"%3B"&[ToLatt]&"%2C"&[ToLong]&"#Map=15/"&[ScreenX]&"/"&[Screeny]&"&layers=N"
2023 update:
I found a very easy way to implement this function.
From google maps, find your POI (point of interest) and click on it.
on left handside opening menu you will see an icon Share and click.
A modal opens and you see a sharing link input box. Next to it you will see Copy link. Go to your url and paste it like;
Drive to our office
Voila, you are done.

How do I remove 'Earth' button from Google Maps?

I'm using the Google Maps generator to create a few maps for a client. The maps embeded on the site are a bit small (255x176), so map real state is crucial. I've already removed the balloon, but can't find a way to remove the "Earth" view button from it (all newly generated maps come with it now, 4 views in total).
The annoying part is that the "Earth" view requires a Google Earth plugin to be used anyway, something the client could live without - me too.
Any advices there? Feedback will be greatly appreciated!
Cheers,
Wallace
You may customize the map controls using the MAPS API.
Visit http://code.google.com/apis/maps/documentation/javascript/controls.html#DefaultUI
Look for MapTypeControlOptions and pass appropriate map type you want to show.
Refer http://code.google.com/apis/maps/documentation/javascript/reference.html#MapTypeControlOptions
http://code.google.com/apis/maps/documentation/javascript/reference.html#MapTypeId
If using the default UI, you would get only the map types in G_DEFAULT_MAP_TYPES, which does not include the Earth map type (G_SATELLITE_3D_MAP).
This means your generator is adding this map type explicitly. So you should be able to simply look for G_SATELLITE_3D_MAP in the javascript you get from the generator, and remove references to it.
If you are still having troubles, can you provide a link to the map generator you are using?

How could a share a Google map mashup with my own datapoints and links back to my site?

I currently have a map mashup that has locations that I'm populating from my own database. A few users would like to also show that map on their site(s). I'd like to give them the ability to do that, but would like to retain the actual functionality of the map on my own site: like add "stuff" to places on the map through my a web form on my site. I could open the entire API to allow them to create their own form along with the data points, but most of the people wanting to put up the map aren't developers, they are just enthusiasts that have put together a personal page that they want to spice up.
I was thinking I could just provide a JavaScript of some kind that they could then take to place on their site, or maybe an IFRAME of some type, or...any ideas? Anyone implemented this? TIA.
I haven't done anything like this myself, but I think your idea to utilise an iframe is on the right track. In fact, this is how Google Maps generates its embed code.
Your app will need to generate a URL with all relevant Google Map parameters such as bounds, zoom level as well as your application-specific params. Any event that triggers the map to re-draw (drag, zoom, etc.) will generate a new URL.
If you try the embed link in Google Maps as an example, it generates a URL that looks something like this:
http://maps.google.com/maps?f=q&source=s_q&sll=45.434035,12.339057&sspn=0.003294,0.004812&ie=UTF8&ll=45.432724,12.338966&spn=0.006588,0.009624&t=h&z=17
This URL can then be wrapped up in an iframe which your end users can place on their web pages.
Re: resizing
Yes, it's possible to dynamically resize it if width/height is part of your application params that generates the embed code. Again using Google Maps as an example:
<iframe
src="http://maps.google.com/maps?f=q&source=s_q&sll=45.434035,12.339057&sspn=0.003294,0.004812&ie=UTF8&ll=45.432724,12.338966&spn=0.006588,0.009624&t=h&z=17&output=embed"
width="(width-param)" height="(height-param)"></iframe>
If you mean resized by user, after it's been displayed, I'm not sure.. most likely, yes.