Git Product home page Git Product logo

Comments (3)

cairabbit avatar cairabbit commented on August 26, 2024

Hi, thanks for your awesome editor. I've made some changes to make it supports zoom.
Below are changes I made:

on "GMaps.controller.js"

I added an event:

    function addZoomChangedListender() {
        google.maps.event.addListener(map, 'zoom_changed', function () {
            var newLocation = marker.getPosition();
            map.setCenter(newLocation);
            lookupPosition(newLocation);
        });
    }

and this event is registered in initializeMap(), just after line "addPlaceChangedListener();"

    addPlaceChangedListener();
    addZoomChangedListender();

then in "lookupPosition" method, append the zoom value to model value:

    var newLng = marker.getPosition().lng();
    var newLat = marker.getPosition().lat();
    var zoom = map.getZoom();
    $scope.model.value = newLat + "," + newLng + "," + zoom;

and then in showing map: initializeMap() method, set the zoom into options:

       var zoom = defaultZoomLvl;
        if(location != ''){
            var latLngArray = location.split(',');

            mapCenter = new google.maps.LatLng(latLngArray[0], latLngArray[1]);
            if (latLngArray.length >= 3)
                zoom = parseFloat(latLngArray[2]);
        }
        else {
            mapCenter = new google.maps.LatLng(defaultLat, defaultLng);
        }

        var mapElement = document.getElementById($scope.model.alias + '_map');
        var mapOptions = { zoom: zoom, center: mapCenter, mapTypeId: google.maps.MapTypeId.ROADMAP };

on "GMapsLocation.cs", add zoom property:

public struct GMapsLocation
{
    public decimal Lat { get; set; }
    public decimal Lng { get; set; }
    public decimal Zoom { get; set; }
}

and on "GMapsValueConverter.cs", set the zoom value to GMapsLocation:

        var loc = new GMapsLocation
        {
            Lat = decimal.Parse(coordinates[0]),
            Lng = decimal.Parse(coordinates[1]),
            Zoom = 15m
        };
        if (coordinates.Length > 2)
        {
            loc.Zoom = decimal.Parse(coordinates[2]);
        }
        return loc;

from umbraco-v7-property-editors-gmaps.

cairabbit avatar cairabbit commented on August 26, 2024

Hope that helps.

from umbraco-v7-property-editors-gmaps.

netaddicts avatar netaddicts commented on August 26, 2024

Please submit pull request

from umbraco-v7-property-editors-gmaps.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.