Last active
September 27, 2016 08:53
-
-
Save hayatbiralem/fba9549da3f49445abef31c5c3495edc to your computer and use it in GitHub Desktop.
Multiple Maps on BP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function BPMap(id, options){ | |
| if(!BPMap.googleMapsLoaded()) { return; } | |
| options = options || {}; | |
| if(!id || !options.lat || !options.lng) return; | |
| options.latlong = {lat: options.lat, lng: options.lng}; | |
| options.zoom = options.zoom || 17; | |
| options.type = options.type || 'roadmap'; | |
| options.title = options.title || 'Konumum'; | |
| options.content = options.content || false; | |
| var map = new google.maps.Map(document.getElementById(id), {center: options.latlong, zoom: options.zoom, streetViewControl: false, panControl: false, mapTypeId: options.type, mapTypeControl: false, zoomControlOptions: {position: google.maps.ControlPosition.LEFT_CENTER}}); | |
| var marker = new google.maps.Marker({position: options.latlong, map: map, title: options.title}); | |
| if(options.content){ | |
| var infowindow = new google.maps.InfoWindow({content: options.content}); | |
| marker.addListener('click', function () { | |
| infowindow.open(map, marker); | |
| }); | |
| } | |
| } | |
| BPMap.googleMapsLoaded = function(){ | |
| return window.google && window.google.maps; | |
| }; | |
| (function(w){ | |
| w.bpMapsInit = function(){ | |
| var q = w[w['BPMapsObject']].q, i=0; | |
| for(; i<q.length; i++){ | |
| BPMap.apply(w, q[i]); | |
| } | |
| w[w['BPMapsObject']] = function(){ | |
| BPMap.apply(w, arguments); | |
| }; | |
| }; | |
| if(BPMap.googleMapsLoaded()) { | |
| w.bpMapsInit(); | |
| } else { | |
| // load script with callback | |
| var async = function (u, c) { | |
| var d = document, t = 'script', | |
| o = d.createElement(t), | |
| s = d.getElementsByTagName(t)[0]; | |
| o.src = '//' + u; | |
| if (c) { o.addEventListener('load', function (e) { c(null, e); }, false); } | |
| s.parentNode.insertBefore(o, s); | |
| }; | |
| async('maps.googleapis.com/maps/api/js?key=AIzaSyB-hvgTCOiFDXtQjI2i9RkvswvjoEgMmic&callback=bpMapsInit'); | |
| } | |
| })(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment