Coder Social home page Coder Social logo

bayan1987 / android-image-map Goto Github PK

View Code? Open in Web Editor NEW

This project forked from maoqis/android-image-map

0.0 1.0 0.0 113 KB

An implementation of an HTML map like element in an Android View: 一个实现类似地图气泡提示,类似HTML <map>标签元素的Android组件。

Java 100.00%

android-image-map's Introduction

An implementation of an HTML map like element in an Android View: 一个实现类似地图气泡提示,类似HTML 标签元素的Android组件。

#(演示)Sample

See ImageMapTestActivity 详见ImageMapTestActivity

public class ImageMapTestActivity extends Activity implements OnBubbleClickListener,OnShapeClickListener{
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        final ImageMapLayout imageMapView = (ImageMapLayout)findViewById(R.id.map);
        
       	imageMapView.setImageResource(R.drawable.gridmap);
	    
		Shape shape1 = new Shape("Shape-1-data", "118,124,219,226");
		Shape shape2 = new Shape("Shape-2-data", "474,374,574,476");
		Shape shape3 = new Shape("Shape-3-data", "710,878,808,980");
		int id1 = imageMapView.addShape(shape1);
		int id2 = imageMapView.addShape(shape2);
		int id3 = imageMapView.addShape(shape3);
		
		//设置Bubble显示方式
		
		TextView view1 = new TextView(this);
		view1.setText("Bubble(1)View");
		view1.setPadding(10, 10, 10, 10);
		view1.setBackgroundColor(Color.BLACK);
		imageMapView.addBubble(view1, id1);	 
		
		TextView view2 = new TextView(this);
		view2.setText("Bubble(2)View");
		view2.setPadding(10, 10, 10, 10);
		view2.setBackgroundColor(Color.BLACK);
		imageMapView.addBubble(view2, id2);	  
		
		TextView view3 = new TextView(this);
		view3.setText("Bubble(3)View");
		view3.setPadding(10, 10, 10, 10);
		view3.setBackgroundColor(Color.BLACK);
		imageMapView.addBubble(view3, id3);
		
		imageMapView.setOnBubbleClickeListener(this);
		imageMapView.setOnShapeClickeListener(this);
       
    }

	@Override
	public void onShapeClick(ImageMap imageMap, int shapeId) {
		imageMap.showBubble(true, shapeId);
	}

	@Override
	public void onBubbleClick(Bubble bubble, int shapeId) {
		Toast.makeText(this, "Click Bubble view:shapeid="+shapeId+" data="+bubble.data, Toast.LENGTH_SHORT).show();
	}
}

#LICENSE /* * Copyright (C) 2011 Scott Lund * Copyright (C) 2013 [email protected] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */

android-image-map's People

Watchers

 avatar

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.