Google Maps iframe not showing dropped pins centered - google-maps

I am trying to add two maps to my website, each with two drop pins. Users can switch between the two maps by clicking on tabs. I built the two maps using the Google Maps Engine. The first map appears great, zoomed in to the right amount and showing the two pins. However, the second map is totally off. I tried doing what was suggested in this previous question Marker not centering in iframe for google map but 1) it was still off and 2) I was unable to add a second pin to the map (plus the map did not look as nice as the iframe I embedded directly on to the site).
Here is the JsFiddle: http://jsfiddle.net/SbH3Y/5/
Google Maps iframes:
<iframe src="http://mapsengine.google.com/map/embed?mid=zzFoZgN4yc_E.kT_V1HoEUMHs" width="461" height="350" scrolling='no' marginheight='0' marginwidth='0'></iframe>
Thanks

You need to reload the iframe in the 2nd tab when it gets selected. The best would be when you initially have an empty iframe and set the src at the first time the tab will be selected.
simple reloading of the frame would be easy:
$('#pickup-date2').show(0,function(){
$('iframe',this)
.attr('src','http://mapsengine.google.com/map/embed?mid=zzFoZgN4yc_E.kT_V1HoEUMHs');
});
http://jsfiddle.net/doktormolle/jUVuB/
But this would reload the iframe each time you select the tab.
Better approach:
the iframe:
<iframe src="about:blank"
data-src="http://mapsengine.google.com/map/embed?mid=zzFoZgN4yc_E.kT_V1HoEUMHs"
width="461" height="350"></iframe>
As you see the map initially will not be loaded, the src is blank and the URL of the map is stored in the data-src-attribute
the script:
$('#pickup-date2')
.show(0,function(){
//when the iframe has data-src
if($('iframe',this).data('src')){
$('iframe',this)
//set the src-attribute
.attr('src',$('iframe',this).data('src'))
//and set data-src to null,
//so the iframe will only be reloaded on the first click
.data('src',null);
} });
http://jsfiddle.net/doktormolle/tWCUR/

Related

Embed a map with satellite terrain active (iframe)

I have this iframe, generated in Google Maps.
<iframe src="https://www.google.com/maps/d/u/0/embed?mid=1ssxg5qgL8pDlVKV4Jcc4axK_O9s2DYm2&ehbc=2E312F" width="100%" height="480"></iframe>
I would like to know if it is possible force the map to be displayed with the satellite image activated. Thanks.
Yes, it is possible, but you need to change it in MyMaps before you create the embedded <frame>. See: http://www.geocodezip.com/SO_20220206_embeddedSat.html
The top map is your original, the bottom map is a copy with the base map changed "satellite".
To change the base map, click on "Base Map" in the left hand menu:
Then choose the image of the satellite tiles:
Then share and capture the new embedded <iframe> with a potentially new URL (might actually be the same).

Embed Google Maps list of places in website

I know Google Maps lets you embed specific places using an <iframe> HTML object, but the embedded map is limited to just a single location. Is there any way to embed a list of locations that I created on Google Maps into a website?
want this result?
here the the list to do to have this
go to google MYMAPS https://www.google.com/maps/d/
click the red button "CREATE NEW MAP"
rename the map, if you want
now click the icon for choosing your desiderated place
do it for 2 or times (in my chase I do it for 3 times)
click the preview button
now you will have 3 cities or places
click share button
now click get code to embed in my website
set to public this.
now you have embedded code
finally you have a maps embed with more places assigned
<iframe src="https://www.google.com/maps/d/embed?mid=1RK0XAw_xdwqvXzdk2tibWWrqKoXpza53&ehbc=2E312F" width="640" height="480"></iframe>

Zoom Controls in google maps URL

I am building Google Map URL that will point few locations in the map
I want to add Zoom control to the map so users can zoom in and out
all the examples i saw were for java script and coding maps
is there any parameter i can add to the url to get the zooming control
I tried
&callback=initMap
&gestureHandling=cooperative
but non worked
any one know what i have to add to get scrolling and zooming controls?
my current URL looks like this
https://maps.googleapis.com/maps/api/staticmap?zoom=13&gestureHandling=cooperative&size=1200x800&maptype=roadmap&key=AIza***********************&markers=label:1%7C-33.87277000,151.21408000&markers=label:2%7C-33.87257000,151.21520000
Based on the URL request that you have included in your question, I can tell that you are not using Maps URL. Instead, you are using Static Maps API. From the word Static itself, its characterized by a fixed or stationary condition.
Once the map is loaded using Static Maps API, the map will be rendered as an image, therefore, no interactions can be done with the map after loading. You may only adjust the zoom level by adjusting the parameter zoom in the URL.
If you want to be able to dynamically move around the map after loading, then you should opt to using Google Maps Javascript API.
But it seems to me that you are trying to avoid using codes. If this is the case and you just want to load the map using url, then you may use Google Maps URL
https://www.google.com/maps/search/?api=1&query=pizza+seattle+wa
If you want to embed a map to a webpage, then you should use Google Maps Embed API. You do not need an to use javascript codes for this one, just an HTML iframe.
<iframe
width="600"
height="450"
frameborder="0" style="border:0"
src="https://www.google.com/maps/embed/v1/place?key=YOUR_API_KEY
&q=Space+Needle,Seattle+WA" allowfullscreen>
</iframe>
Hope this helps!

add search bar function to embedded google html map

I created a map using the new Google Maps and I am using the "embed this to my site" feature, but it has no search bar. The intent of the map is to enter an address to see if you fall within a boundary I created but I don't know how to alter the HTML code to add a search feature. I also have next to no HTML experience, so please be kind.
Here is what I have as the embed code:
No actual space between first < and iframe but I added it for it to show up
<iframe src="https://mapsengine.google.com/map/embed?mid=z-3d_xUUkSNQ.kL7YAhEFIavc" width="640" height="480">
</iframe>
There are many things you can do. One idea is you can use the address provided by your users to obtain the coordinate of the location. This can be done via google Geocoding service. Then from there you can determine if the given address falls within the region you have provided. You probably want to start playing around with HTML and Javascript first for a more complicated task like this.

Centering InfoWindow Google Map IFrame

Is there a way to center the pop up window (info window) on a google map iFrame to make sure that it does not get cut off?
WOuld it be easier for me to use the Google Map API instead of iFrame? If so, is there an API call that would give me the same information by default on a the infoWIndow?
Note: I have tried using Google Map API and I prefer this over using iFrame. The only downside is that I do not get the extra information that comes with using google map iFrame. It looks like I need to populate this window with HTML by myself.
Btw here's a good example of how to create a custom InfoWindow.
https://developers.google.com/maps/documentation/javascript/overlays#InfoWindows
You can use any html such as custom headers, divs and links
And here's the Placed API with Google Maps:
https://developers.google.com/maps/documentation/javascript/places