Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /* global google */
- var map;
- // Creating icon links to iterate through randomly
- var icons = [
- 'http://maps.google.com/mapfiles/ms/icons/red-dot.png',
- 'http://maps.google.com/mapfiles/ms/icons/green-dot.png',
- 'http://maps.google.com/mapfiles/ms/icons/blue-dot.png',
- 'http://maps.google.com/mapfiles/ms/icons/orange-dot.png',
- 'http://maps.google.com/mapfiles/ms/icons/purple-dot.png',
- 'http://maps.google.com/mapfiles/ms/icons/pink-dot.png',
- 'http://maps.google.com/mapfiles/ms/icons/yellow-dot.png'
- ];
- var infoWindows =[
- "<b> testing one two three </b> <br> <img src = 'http://maps.google.com/mapfiles/ms/icons/yellow-dot.png'>"
- ];
- // Initialising The map with settings
- function initialise() {
- var mapOptions = {
- center: new google.maps.LatLng(0, 0),
- zoom: 4,
- mapTypeId: google.maps.MapTypeId.SATELLITE,
- zoomControlOptions: {
- position: google.maps.ControlPosition.LEFT_BOTTOM
- }
- };
- map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
- }
- google.maps.event.addDomListener(window, 'load', initialise);
- // **********************************start of button 1 ***********************************
- function newCenter() {
- var prompt1 = prompt('enter lat');
- var prompt2 = prompt ('enter long');
- var relocate = new google.maps.LatLng(prompt1, prompt2)
- map.panTo(relocate);
- new google.maps.Marker({
- position: relocate,
- icon: icons[Math.floor(Math.random()*icons.length)],
- map: map,
- infoWindow : infoWindows[0]
- });
- }
- // **********************************start of button 2***********************************
- function button2(){
- var random1 = Math.round((Math.random()*180 - 180)* 1000)/1000;
- var random2 = Math.round((Math.random()*180 - 180)*1000)/1000;
- var relocate2 = new google.maps.LatLng(random1, random2)
- map.setCenter(relocate2);
- }
- // **********************************start of button 3***********************************
- var markON = false;
- function button3(){
- if(!markON){
- markON=true;
- mapsListener = google.maps.event.addListener(map, 'click', function(e) {
- placeMarker(e.latLng, map);
- });
- function placeMarker(position, map) {
- var marker = new google.maps.Marker({
- position: position,
- map: map,
- icon: icons[Math.floor(Math.random()*icons.length)]
- });
- map.panTo(position);
- }
- }
- else {
- markON = false;
- google.maps.event.removeListener(mapsListener);
- }
- }
- // **********************************start of button 4***********************************
- var countPoly = 0;
- var area = new google.maps.MVCArray();
- var polygon = new google.maps.Polygon({
- path: area,
- map:map,
- strokeOpacity: 0.5,
- strokeWeight: 6,
- strokeColor: "#0000FF",
- fillOpacity: 0.5,
- fillColor: "#00000F",
- clickable:false
- });
- var listenON=false;
- function button4()
- {
- if(!listenON){
- listenON=true;
- polygon.setMap(map);
- drawListener = google.maps.event.addListener(map, 'click', function (x) {
- countPoly++;
- var path = polygon.getPath();
- path.push(x.latLng)
- var marker = new google.maps.Marker({
- position: x.latLng,
- map: map,
- icon: icons[Math.floor(Math.random()*icons.length)]
- });
- google.maps.event.trigger(marker, 'click');
- });
- }
- else
- {
- listenON=false;
- google.maps.event.removeListener(drawListener);
- }
- }
- // **********************************start of button 4***********************************
- var highlightListenON = false;
- function button5(){
- var countPoly = 0;
- var area = new google.maps.MVCArray();
- var polygon = new google.maps.Polygon({
- path: area,
- map:map,
- strokeOpacity: 0.5,
- strokeWeight: 6,
- strokeColor: "#0000FF",
- fillOpacity: 0.5,
- fillColor: "#00000F",
- clickable:false
- });
- if(!highlightListenON){
- highlightListenON = true;
- drawListener = google.maps.event.addListener(map, 'click', function(e){
- countPoly++;
- })
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement