Code Monkey home page Code Monkey logo

azure-maps-scale-bar-control's Introduction

page_type description languages products
sample
An Azure Maps Web SDK module that provides a control that displays a scale bar relative to the pixel resolution at the center of the map.
javascript
typescript
azure
azure-maps

This is now built into Azure Maps Web SDK under atlas.control.ScaleControl

Azure Maps Scale Bar Control module

An Azure Maps Web SDK module that provides a control that displays a scale bar relative to the pixel resolution at the center of the map.

Samples

Simple Scale Bar Control

Getting started

Download the project and copy the azure-maps-scale-bar-control JavaScript file from the dist folder into your project.

Usage

//Add scale bar control to the map.
map.controls.add(new atlas.control.ScaleBarControl());

API Reference

ScaleBarControl class

Implements: atlas.Control

Namespace: atlas.control

A control that displays a scale bar relative to the pixel resolution at the center of the map.

Contstructor

ScaleBarControl(options?: ScaleBarControlOptions)

ScaleBarControlOptions interface

Properties

Name Type Description
maxBarLength number The maximum length of the scale bar in pixels. Default: 100
units 'imperial' | 'metric' | 'meters' | 'kilometers' | 'yards' | 'feet' | 'miles' | 'nauticalMiles' The distance units of the scale bar. Default: 'imperial'

Related Projects

Additional Resources

Contributing

We welcome contributions. Feel free to submit code samples, file issues and pull requests on the repo and we'll address them as we can. Learn more about how you can help on our Contribution Rules & Guidelines.

You can reach out to us anytime with questions and suggestions using our communities below:

This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

License

MIT

See License for full license text.

azure-maps-scale-bar-control's People

Contributors

microsoft-github-operations[bot] avatar microsoftopensource avatar rbrundritt avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

azure-maps-scale-bar-control's Issues

Scale is based on the top of the map instead of the center

When we implemented our own distance measuring tool I noticed that the scale bar was off. It seemed to be correct on the top of the map, instead of at the centre like expected. I think there is an error in the _updateScaleBar method. The documentation of camera.center says it returns positions, but it is used as pixels here.

var cp = self._map.pixelsToPositions([camera.center]);

changing this line to use positionsToPixels() instead of pixelsToPositions() solved the issue in our project.

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.