I have been googling about it a lot, but couldn't find any appreciable opinion over the same,
I need to incorporate a static google map image in a jQuery Mobile project, for building an app with phonegap. The map image has to fill the viewport almost completely. Question is how, as it will obviously be opened across different devices of different screen sizes. I have tried with the percentage approach, but that certainly doesn't work here.
I would like to get some guidance on keeping the layout for the google map static image in a fluid layout, in the simplest possible way (Please, if possible).
Thanks
Since the map produced is a static image, it won't be interactive or tailored to the user but it can be stylised through the custom parameters.
Note that the Maps Embed API, Maps SDK for Android, and Maps SDK for iOS currently have no usage limits and are at no charge (usage of the API or SDKs is not applied against your $200 monthly credit).
The Maps Static API lets you embed a Google Maps image on your web page without requiring JavaScript or any dynamic page loading. The Maps Static API service creates your map based on URL parameters sent through a standard HTTP request and returns the map as an image you can display on your web page.
load the largest image size you are going to need initially into a container e.g. size of 380 x 250
this will be position:relative with overflow hidden and max size you need.
figre
{
position:relative;
width: 100%;
overflow:hidden;
}
then absolutely position the using top & left to position the image centrally inside the container.
e.g.
figure img
{
position: absolute;
top: calc(50% - 125px);
left: calc(50% - 190px);
}
I have tried to style Google Static Map to follow the Bootstrap by referring to this website http://webdesigntutsplus.s3.amazonaws.com/tuts/365_google_maps/demo/index.html
<div class="col-sm-8 map-wrapper">
<a target="_blank" class="map-container" href="LINK_TO_GOOGLE_MAP">
<img src="YOUR_GOOGLE_STATIC_MAP_QUERY">
</a>
</div>
a.map-container {
display: block;
background-image: url("YOUR_GOOGLE_STATIC_MAP_QUERY");
background-repeat: no-repeat;
background-position: 50% 50%;
line-height: 0;
}
.map-container img
{
max-width: 100%;
opacity: 0;
}
The static map now is responsive on my website. I am not sure if it is applicable to you, but this is how I do it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With